Changes between Version 2 and Version 3 of CookBook join RHT-BDMAP


Ignore:
Timestamp:
May 20, 2011 10:49:18 AM (14 years ago)
Author:
celine
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBook join RHT-BDMAP

    v2 v3  
    99 
    1010Problème de projections !!! A vérifier en cours ! 
     11{{{ 
    1112-- creation de la table bdmap_rht, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis   
    1213DROP TABLE IF EXISTS rht.bdmap_rht; 
    1314CREATE TABLE rht.bdmap_rht as ( 
    14         SELECT distinct on (st_codecsp) st_codecsp, gid, min(distance) as distance, the_geom FROM ( 
    15                SELECT st_codecsp, gid ,CAST(distance(r.the_geom, s.the_geom) as  decimal(15,1)) as distance,s.the_geom  
     15        SELECT distinct on (st_codecsp) st_codecsp, id_drain, min(distance) as distance, the_geom FROM ( 
     16               SELECT st_codecsp, id_drain ,CAST(distance(r.the_geom, s.the_geom) as  decimal(15,1)) as distance,s.the_geom  
    1617               FROM bd_map.stationsp2 As s 
    17                INNER JOIN  rht.riversegments r ON ST_DWithin(r.the_geom, s.the_geom,300) 
     18               INNER JOIN  rht.rht r ON ST_DWithin(r.the_geom, s.the_geom,300) 
    1819               WHERE s.the_geom IS NOT NULL 
    1920               ORDER BY st_codecsp) AS sub  
    20         GROUP BY st_codecsp, distance,gid, the_geom 
     21        GROUP BY st_codecsp, distance,id_drain, the_geom 
    2122); 
    2223alter table rht.bdmap_rht add column id serial; 
     
    3334CREATE INDEX indexbdmap_rht ON rht.bdmap_rht 
    3435  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
    35  
     36}}}