Changes between Version 11 and Version 12 of Import impact data to dbeel


Ignore:
Timestamp:
Jan 3, 2019 5:37:56 PM (6 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Import impact data to dbeel

    v11 v12  
    2121 
    2222This is the most complete table we have for spain, it's been sent by the ministry, and we will import it first and then import other data. 
    23 One of the problem we must solve it that this layer has several points nearly on top of each other (e.g. one per "dike" on each dam). So when calculated multiple impact we might run into problems https://trello.com/c/IIMjWVkX 
    24  
    25 {{{#!sql 
    26 -- !!! some duplicate inside the spain_obstruction_in_spain table 
    27 -- eg SO_288 and SO_874 which have different ALT_CAU !!! 
    28 -- internal duplicate here 
    29 WITH duplicate AS 
    30 ( 
    31         SELECT sp1.id AS id1, sp2.id AS id2 FROM sudoang.spain_obstruction_in_spain AS sp1, sudoang.spain_obstruction_in_spain AS sp2 
    32         WHERE substring(sp1.id from 4) < substring(sp2.id from 4) AND ST_Distance(sp1.geom, sp2.geom)<0.01 
    33 ) SELECT *, rank() OVER(PARTITION BY id1 ORDER BY id2) FROM duplicate ORDER BY substring(id1 from 4)::integer 
    34 ; 
    35 }}} 
    36 ||id1||id2||rank|| 
    37 ||SO_14||SO_15||1|| 
    38 ||SO_14||SO_17||3|| 
    39 ||SO_14||SO_16||2|| 
    40 ||SO_15||SO_16||1|| 
    41 ||SO_15||SO_17||2|| 
    42 ||SO_16||SO_17||1|| 
    43 ||SO_42||SO_44||1|| 
    44  
    4523 
    4624 
     
    8765) sub --415 
    8866}}} 
     67 
     68 
     69 
     70 
     71 
     72 
     73 
     74One of the problem we must solve it that this layer has several points nearly on top of each other (e.g. one per "dike" on each dam). So when calculated multiple impact we might run into problems https://trello.com/c/IIMjWVkX 
     75 
     76{{{#!sql 
     77-- !!! some duplicate inside the spain_obstruction_in_spain table 
     78-- eg SO_288 and SO_874 which have different ALT_CAU !!! 
     79-- internal duplicate here 
     80WITH duplicate AS 
     81( 
     82        SELECT sp1.id AS id1, sp2.id AS id2 FROM sudoang.spain_obstruction_in_spain AS sp1, sudoang.spain_obstruction_in_spain AS sp2 
     83        WHERE substring(sp1.id from 4) < substring(sp2.id from 4) AND ST_Distance(sp1.geom, sp2.geom)<0.01 
     84) SELECT *, rank() OVER(PARTITION BY id1 ORDER BY id2) FROM duplicate ORDER BY substring(id1 from 4)::integer 
     85; 
     86}}} 
     87||id1||id2||rank|| 
     88||SO_14||SO_15||1|| 
     89||SO_14||SO_17||3|| 
     90||SO_14||SO_16||2|| 
     91||SO_15||SO_16||1|| 
     92||SO_15||SO_17||2|| 
     93||SO_16||SO_17||1|| 
     94||SO_42||SO_44||1|| 
     95 
     96We have also reprojected all data and created a unique id for all tables, the id is 
     97 
     98v 
     99 
     100|| prefix || table || 
     101|| SO || Spain_obstruction &  spain_obstruction_in_spain || 
     102|| CO || Catalonia_obstruction (deprecated) || 
     103|| COD || catalonia_obstruction_dams || 
     104|| COH || catalonia_obstruction_hpp || 
     105|| MIO  || minho_obstruction || 
     106|| MIO  || minho_obstruction || 
     107|| AFR || Amber France || 
     108|| AFS || Amber Spain || 
     109|| FC || fcul_obstruction || 
     110 
     111 
     112To join the data COD and COH it's a bit complex, see the script, instead of indentifying the mother table,  the daughter table is idenditied. This was done with a list of coma separated value, first we had to correct it (remove space, replace `;` with `,`). To join the two tables we had to create an intermediate table `catalonia_obstruction_join_dams_hpp` 
     113source:eda/EDAcommun/sql/sudoang/dbeel_sudoang_obstruction.sql  [[BR]] 
     114 
    89115 
    90116== Create the dbeel database ==