Changes between Version 6 and Version 7 of CLC Join


Ignore:
Timestamp:
May 31, 2010 1:14:35 PM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CLC Join

    v6 v7  
    3434        where substring(code_00 from 1 for 1)='1' )  AS intersected;             
    3535 
     36-- script de départ (modifié ensuite) 
     37CREATE TABLE clc.clipped_bretagne AS 
     38SELECT intersected.clcgid, intersected.gid, clipped_geom 
     39FROM (SELECT clc.gid as clcgid, c.gid, ST_Multi(ST_Intersection(clc.the_geom, c.the_geom)) clipped_geom 
     40        FROM  clc.clc00_v2_europe clc INNER JOIN ccm21.catchments c 
     41        ON  ST_Intersects (c.the_geom,clc.the_geom) 
     42        WHERE c.wso_id IN (SELECT wso_id FROM france.wso WHERE area='Bretagne') 
     43        AND substring(code_00 from 1 for 1)='1')  AS intersected;--3721 lines   
     44ALTER TABLE clc.clipped_bretagne add column id serial PRIMARY KEY; 
     45 
     46-3721 lines   
     47ALTER TABLE clc.clipped_bretagne add column id serial PRIMARY KEY; 
     48-- ajout dans la table geometry_columns pour référencement rapide sous Qgis 
     49INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     50SELECT '', 'clc', 'clipped_bretagne', 'the_geom', ST_CoordDim(clipped_geom), ST_SRID(clipped_geom), MULTIPOLYGON 
     51FROM clc.clipped_bretagne  LIMIT 1; 
     52 
     53-- ci dessous j'essaye d'analyser la structure interne des données pour comprendre quels sont les problèmes 
     54 
     55SELECT intersected.clcgid, intersected.gid, intersected.the_geom 
     56FROM (SELECT clc.gid as clcgid, c.gid, CAST(ST_AsText(ST_Multi(ST_Intersection(clc.the_geom, c.the_geom))) as VARCHAR(150)) as the_geom 
     57        FROM  clc.clc00_v2_europe clc INNER JOIN ccm21.catchments c 
     58        ON  ST_Intersects (c.the_geom,clc.the_geom) 
     59        WHERE c.wso_id IN (SELECT wso_id FROM france.wso WHERE area='Bretagne') 
     60        AND substring(code_00 from 1 for 1)='1')  AS intersected; 
     61 
     62 
     63-- Pour comparaison (ressemble beaucoup) 
     64 
     65SELECT CAST(ST_AsText(the_geom) as varchar(150)) from clc.clc00_v2_europe clc limit 20; 
     66 
     67 
     68-- Je rééssaye 
     69DROP TABLE IF EXISTS clc.clipped_bretagne; 
     70CREATE TABLE clc.clipped_bretagne AS 
     71SELECT intersected.clcgid, intersected.gid, the_geom 
     72FROM (SELECT clc.gid as clcgid, c.gid, ST_Multi(ST_Intersection(clc.the_geom, c.the_geom)) the_geom 
     73        FROM  clc.clc00_v2_europe clc INNER JOIN ccm21.catchments c 
     74        ON  ST_Intersects (c.the_geom,clc.the_geom) 
     75        WHERE c.wso_id IN (SELECT wso_id FROM france.wso WHERE area='Bretagne') 
     76        AND substring(code_00 from 1 for 1)='1')  AS intersected;--3721 lines   
     77ALTER TABLE clc.clipped_bretagne add column id serial PRIMARY KEY; 
     78-- Here to analyse the structure of data in the created table 
     79SELECT ST_AsText(the_geom) from clc.clipped_bretagne limit 20; 
     80 
     81-- celui là marche sur Postgis (et je ne comprends pas ce qui ne marchait pas peut être le as the_geom a la place de the_geom, ou alors mon Qgis....) 
     82 
     83-- I'm adding some original data tables restricted for an area for Qgis easy use 
     84-- extraction of a clc table for Britany 
     85DROP TABLE IF EXISTS clc.clc00_v2_Bretagne; 
     86CREATE TABLE clc.clc00_v2_Bretagne AS 
     87SELECT * FROM clc.clc00_v2_europe where gid IN ( 
     88SELECT gid FROM  clc.clc00_v2_europe clc JOIN 
     89    (SELECT the_geom FROM france.region where code_reg='53') as sub 
     90    ON ST_Contains(sub.the_geom,clc.the_geom)); 
     91ALTER TABLE clc.clc00_v2_Bretagne ADD CONSTRAINT c_pk_gid PRIMARY KEY  (gid); 
     92INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     93SELECT '', 'clc', 'clc00_v2_Bretagne', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     94FROM clc.clc00_v2_europe LIMIT 1; 
     95 
     96-- Creating a table for riversegments Bretagne 
     97 
     98DROP TABLE IF EXISTS ccm21.riversegments_Bretagne;    
     99CREATE TABLE  ccm21.riversegments_Bretagne AS 
     100    SELECT * FROM ccm21.riversegments 
     101        WHERE wso_id IN (SELECT wso_id FROM france.wso WHERE area='Bretagne'); 
     102ALTER TABLE ccm21.riversegments_Bretagne ADD CONSTRAINT c_pk_gid_riversegments_Bretagne PRIMARY KEY  (gid); 
     103INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     104SELECT '', 'ccm21', 'riversegments_Bretagne', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     105FROM ccm21.riversegments_Bretagne LIMIT 1; 
     106 
     107-- creating a table for catchments Bretagne. 
     108DROP TABLE IF EXISTS ccm21.catchments_Bretagne;    
     109CREATE TABLE  ccm21.catchments_Bretagne AS 
     110    SELECT * FROM ccm21.catchments 
     111        WHERE wso_id IN (SELECT wso_id FROM france.wso WHERE area='Bretagne');   
     112ALTER TABLE ccm21.catchments_Bretagne ADD CONSTRAINT c_pk_gid_catchments_Bretagne PRIMARY KEY  (gid); 
     113INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     114SELECT '', 'ccm21', 'catchments_Bretagne', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     115FROM ccm21.catchments_Bretagne LIMIT 1; 
    36116 
    37117}}}