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


Ignore:
Timestamp:
May 19, 2011 4:31:23 PM (14 years ago)
Author:
celine
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBook join RHT-BDMAP

    v1 v2  
    44 
    55= Joining RHT with BDMAP = 
     6 
     7Joining the riversegment from RHT and stationsp2 (??) 
     8 
     9 
     10Problème de projections !!! A vérifier en cours ! 
     11-- creation de la table bdmap_rht, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis   
     12DROP TABLE IF EXISTS rht.bdmap_rht; 
     13CREATE 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  
     16               FROM bd_map.stationsp2 As s 
     17               INNER JOIN  rht.riversegments r ON ST_DWithin(r.the_geom, s.the_geom,300) 
     18               WHERE s.the_geom IS NOT NULL 
     19               ORDER BY st_codecsp) AS sub  
     20        GROUP BY st_codecsp, distance,gid, the_geom 
     21); 
     22alter table rht.bdmap_rht add column id serial; 
     23-- mise à jour de la table geometry_columns 
     24INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     25SELECT '', 'rht', 'bdmap_rht', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     26FROM rht.bdmap_rht LIMIT 1; 
     27 
     28-- creation d'index, clé primaire, et constraintes qui vont bien 
     29alter table rht.bdmap_rht add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 
     30alter table rht.bdmap_rht add  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); 
     31alter table rht.bdmap_rht add  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 
     32alter table rht.bdmap_rht ADD CONSTRAINT pk_id PRIMARY KEY(id); 
     33CREATE INDEX indexbdmap_rht ON rht.bdmap_rht 
     34  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
     35