Changes between Version 36 and Version 37 of CLC Join


Ignore:
Timestamp:
Jun 1, 2010 12:22:22 PM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CLC Join

    v36 v37  
    6363[[Image(source:data/Docs/trac/coupure des couvertures anthropisées.png,600px)]]  [[BR]] 
    6464== Grouping the surface by gid and code_00 == 
    65 The next steps is to group the different layers, we use the ''' ST_Multi(ST_Collect(()) ''' function to group the POLYGONS into MULTIPOLYGONS (one per line) and before this we do the reverse by transforming all MUTIPOLYGONS into POLYGONS using ''' ST_Dump() '''.  
     65The next steps is to group the different layers, we use the ''' ST_Multi(ST_Collect(()) ''' function to group the POLYGONS into MULTIPOLYGONS (one per line) and before this we do the reverse by transforming all MUTIPOLYGONS into POLYGONS using ''' ST_Dump() '''. So finally calculating the area using ''' ST_Area ''' is a very quick and simple step. Note the unicity constraint wich ensures that we have only one code_00 per unit catchment. 
     66 
     67{{{ 
     68-------------------------------------- 
     69-------------------------------------- 
     70--REGROUPEMENT 
     71-------------------------------------- 
     72-------------------------------------- 
     73 
     74DROP TABLE IF EXISTS clc.clipped_bretagne1; 
     75CREATE TABLE clc.clipped_bretagne1 AS ( 
     76SELECT gid,code_00, 
     77           ST_Multi(ST_Collect(f.the_geom)) as the_geom 
     78         FROM (SELECT gid, code_00,(ST_Dump(the_geom)).geom As the_geom 
     79                                FROM 
     80                                 clc.clipped_bretagne 
     81                                ) As f 
     82GROUP BY gid,code_00); -- 5s 
     83ALTER TABLE clc.clipped_bretagne1 add column id serial PRIMARY KEY; 
     84alter table clc.clipped_bretagne1 add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 
     85alter table clc.clipped_bretagne1 add  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL); 
     86alter table clc.clipped_bretagne1 add  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 
     87CREATE INDEX indexclc00clipped_bretagne1 ON clc.clipped_bretagne1 
     88  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
     89ALTER TABLE clc.clipped_bretagne1 add constraint c_ck_uk  UNIQUE(gid,code_00); -- contrainte d'unicité OK ! 
     90 
     91 
     92ALTER TABLE clc.clipped_bretagne1 add column area numeric; 
     93UPDATE clc.clipped_bretagne1 set area=ST_Area(the_geom); -- 9s 
     94}}}