wiki:Cookbook CCM21_UGA

Version 17 (modified by celine, 15 years ago) (diff)

--

back to first page ..
back to CookBook Eda
back to UGA

     drop table  if exists uga2010.wso;
     CREATE TABLE uga2010.wso (
     id serial PRIMARY KEY,
     wso_id integer,
     uga varchar(25)
     )

--Loire
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='1') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='Loire' where uga IS NULL --40 sea nodes

--Garonne
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='2') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='Garonne' where uga IS NULL --60 sea nodes

--Adour
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='3') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='Adour' where uga IS NULL --19 sea nodes

--Artois-Picardie
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='4') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='ArtoisPicardie' where uga IS NULL --26 sea nodes

--Rhône-M‚diterranée
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='5') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='RhoneMediterranee' where uga IS NULL --133 sea nodes

--Corse
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='6') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='Corse' where uga IS NULL --177 sea nodes

--Seine-Normandie
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='7') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='SeineNormandie' where uga IS NULL --89 sea nodes

--Bretagne
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='8') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='Bretagne' where uga IS NULL --166 sea nodes

--Rhin
    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='9') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='Rhin' where uga IS NULL --2 sea nodes

--Meuse

    insert into uga2010.wso(wso_id) 
    select distinct on (wso_id)  wso_id from ccm21.riversegments r
    join (SELECT ST_Union(f.the_geom) as singlegeom
        FROM uga2010.uga As f where gid='10') as sub
    ON ST_Intersects(sub.singlegeom,r.the_geom);

    UPDATE uga2010.wso set uga='Meuse' where uga IS NULL --3 sea nodes

J'ai un doute pour la requête entre wso_id et wso1_id lequel choisir ??

Problème dans la construction même des UGA
Deux couches d'UGA (Loire et Garonne) se supperpose QGis au niveau de la mer

source:data/Docs/trac/UGA/Supperposition_UGA.jpg

Mais sous ArcGis il ne semble pas y avoir de suppersposition
source:data/Docs/trac/UGA/Supperposition_UGA_ArcGis.jpg

Probleme de segment à cheval sur deux couches

source:data/Docs/trac/UGA/UGA-CCM.jpg

Recherche de doublons

select wso_id, count(wso_id) as nombre from uga2010.wso group by wso_id order by nombre;

Problèmes de doubons avec les riversegments qui sont à cheval sur deux UGA

wso_idnb de doublonsUGA donnésAppartient en réalité à l'UGA (ce que je propose)
2911103Rhin, Meuse, RhoneMediterranee
2911114SeineNormandie, Loire, Garonne et BretagneLoire
2911122RhonemEditerranee, Rhin
2911153ArtoisPicardie, SeineNormandie, Meuse
2911252Loire, GaronneGaronne
2911262Garonne, RhoneMediterraneeGaronne
2911303ArtoisPicardie, Meuse, SeineNormandie
2911942Garonne, Adour
2912232ArtoisPicardie, SeineNormandie
2912492SeineNormandie, Loire
2915132Garonne, RhoneMediterraneeRhoneMediterranee?
2927062Garonne, RhoneMediterraneeGaronne
3097312Loire, GaronneGaronne
4423532Garonne, RhoneMediterranee Aucune idée !||