Changes between Version 31 and Version 32 of import layers postgis


Ignore:
Timestamp:
Jul 13, 2018 12:42:34 PM (7 years ago)
Author:
maria
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • import layers postgis

    v31 v32  
    318318}}} 
    319319 
    320  
    321 ---------------------------------------------- 
    322 -- IMPORT LAYER POSTGIS: UROLA RIVER '1003716%' 
    323 --------------------------------------------------------------------- 
    324 -- 1003716 corresponds to Urola river 
    325 -- Creating a table corresponding to UROLA 
    326 -- Table of basins 
    327 create table spain.urola_cuenca as select * from a_cuencas_rios_atl_norte where pfafrio like '1003716%'; 
    328  
    329 CREATE INDEX urola_cuenca_geom_idx 
    330   ON urola_cuenca 
    331   USING gist 
    332   (geom); 
    333  
    334 -- Table of rivers 
    335 drop table if exists spain.urola_a_rios_v2; 
    336 create table spain.urola_a_rios_v2 as select * from a_rios_v2 where pfafrio like '1003716%'; 
    337  
    338 CREATE INDEX urola_a_rios_v2_geom_idx 
    339   ON urola_a_rios_v2 
    340   USING gist 
    341   (geom); 
    342    
    343 select * from urola_a_rios_v2 limit 10; 
    344  
    345 ALTER TABLE spain.urola_a_rios_v2 DROP COLUMN source; 
    346 ALTER TABLE spain.urola_a_rios_v2 DROP COLUMN target; 
    347 ALTER TABLE spain.urola_a_rios_v2 ADD COLUMN source integer; 
    348 ALTER TABLE spain.urola_a_rios_v2 ADD COLUMN target integer; 
    349 CREATE INDEX urola_a_rios_v2_source_idx ON spain.urola_a_rios_v2 (source); 
    350 CREATE INDEX urola_a_rios_v2_target_idx ON spain.urola_a_rios_v2 (target); 
    351  
    352 --------------------------------------------------------------------- 
    353 -- createTopology also creates spain.urola_a_rios_v2_vertices_pgr 
    354 ------------------------------------------------------------------ 
    355 set search_path to spain,public,european_wise2008; 
    356 SELECT pgr_createTopology('urola_a_rios_v2', 0.0001, 'geom', 'gid');--1.4s 
    357  
    358  
    359  
     320== select some bassins to calculate topology == 
     321 
     322set search_path to public, spain, european_wise2008 ; -- location of the tables in the scheme 
     323 
     324-- Rivers 
     325--select  * from a_rios_v2 limit 10;            -- visualize 10 first rows 
     326--ALTER TABLE a_rios_v2 DROP COLUMN pfafbas;    -- delete columns 
     327--ALTER TABLE a_rios_v2 DROP COLUMN rio; 
     328 
     329ALTER TABLE a_rios_v2 ADD COLUMN pfafbas varchar; 
     330ALTER TABLE a_rios_v2 ADD COLUMN rio varchar; 
     331 
     332UPDATE  
     333   a_rios_v2 
     334SET  
     335   pfafbas = SUBSTR(pfafrio, 1, 5), -- New columns are created as character! 
     336   rio = SUBSTR(pfafrio, 6, 2) 
     337 
     338-- Test with '10037%' that  corresponds to the Biscay coast of Spain: 
     339create table spain.biscay_coast_a_rios_v2 as select * from a_rios_v2 where pfafrio like '10037%'; 
     340 
     341--SELECT *, pfafrio, (SUBSTR(pfafrio, 1, 5) = '10037%') FROM a_rios_v2; -- create a column boolean to say TRUE/FALSE  
     342--SELECT *, SUBSTR(pfafrio, 1, 5) "pfafbas", SUBSTR(pfafrio, 6, 2) "rios" 
     343--FROM a_rios_v2; 
     344 
     345