Changes between Version 61 and Version 62 of CLC Join


Ignore:
Timestamp:
Jun 1, 2010 3:51:49 PM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CLC Join

    v61 v62  
    154154CREATE TABLE clc.surf_area AS ( 
    155155SELECT DISTINCT ON (init.gid) init.gid, 
    156         urban_11_13, 
    157          green_urban_14, 
     156        artificial_surfaces_11_13, 
     157        artificial_vegetated_14, 
    158158         arable_land_21, 
    159          plantations_22, 
     159         permanent_crops_22, 
    160160         pastures_23, 
    161          crops_natural_24, 
     161         heterogeneous_agricultural_24, 
    162162         forest_31, 
    163163         natural_32_33, 
    164164         wetlands_4, 
    165          water_51 , 
    166          seawater_52 
     165         inland_waterbodies_51 , 
     166         marine_water_52 
    167167        -- SELECT *  
    168168         FROM ( 
    169169        SELECT  gid from clc.clipped_bretagne1  ) as init         
    170         FULL OUTER JOIN (SELECT gid,sum(area) AS urban_11_13 FROM clc.clipped_bretagne1 WHERE  
     170        FULL OUTER JOIN (SELECT gid,sum(area) AS artificial_surfaces_11_13 FROM clc.clipped_bretagne1 WHERE  
    171171                        substring(code_00 from 1 for 2)='11'  
    172172                        OR  substring(code_00 from 1 for 2)='12' 
    173173                        OR substring(code_00 from 1 for 2)='13'  
    174                         GROUP BY gid) AS urban 
    175                        on (init.gid) =(urban.gid)                
    176         FULL OUTER JOIN (SELECT gid,sum(area) AS green_urban_14 FROM clc.clipped_bretagne1 WHERE  
     174                        GROUP BY gid) AS artificial_surfaces 
     175                       on (init.gid) =(artificial_surfaces.gid)          
     176        FULL OUTER JOIN (SELECT gid,sum(area) AS artificial_vegetated_14 FROM clc.clipped_bretagne1 WHERE  
    177177                        substring(code_00 from 1 for 2)='14' 
    178                         GROUP BY gid) AS green_urban 
    179                         on green_urban.gid =init.gid 
     178                        GROUP BY gid) AS artificial_vegetated 
     179                        on artificial_vegetated.gid =init.gid 
    180180        FULL OUTER JOIN (SELECT gid,sum(area) AS arable_land_21 FROM clc.clipped_bretagne1 WHERE  
    181181                        substring(code_00 from 1 for 2)='21' 
    182182                        GROUP BY gid) AS arable_land 
    183183                        on arable_land.gid =init.gid 
    184         FULL OUTER JOIN (SELECT gid, sum(area) AS plantations_22 FROM clc.clipped_bretagne1 WHERE  
     184        FULL OUTER JOIN (SELECT gid, sum(area) AS permanent_crops_22 FROM clc.clipped_bretagne1 WHERE  
    185185                        substring(code_00 from 1 for 2)='22' 
    186                         GROUP BY gid) AS plantations 
    187                         on plantations.gid =init.gid 
     186                        GROUP BY gid) AS permanent_crops 
     187                        on permanent_crops.gid =init.gid 
    188188        FULL OUTER JOIN (SELECT gid,sum(area) AS pastures_23 FROM clc.clipped_bretagne1 WHERE  
    189189                        substring(code_00 from 1 for 2)='23' 
    190190                        GROUP BY gid) AS pastures 
    191191                        on pastures.gid =init.gid 
    192         FULL OUTER JOIN (SELECT gid, sum(area) AS crops_natural_24 FROM clc.clipped_bretagne1 WHERE  
     192        FULL OUTER JOIN (SELECT gid, sum(area) AS heterogeneous_agricultural_24 FROM clc.clipped_bretagne1 WHERE  
    193193                        substring(code_00 from 1 for 2)='24' 
    194                         GROUP BY gid) AS crops_natural 
    195                         on crops_natural.gid =init.gid 
     194                        GROUP BY gid) AS heterogeneous_agricultural 
     195                        on heterogeneous_agricultural.gid =init.gid 
    196196        FULL OUTER JOIN (SELECT gid,sum(area) AS forest_31 FROM clc.clipped_bretagne1 WHERE  
    197197                        substring(code_00 from 1 for 2)='31' 
     
    207207                        GROUP BY gid) AS wetlands 
    208208                        on wetlands.gid =init.gid 
    209         FULL OUTER JOIN (SELECT gid,sum(area) AS water_51 FROM clc.clipped_bretagne1 WHERE  
     209        FULL OUTER JOIN (SELECT gid,sum(area) AS inland_waterbodies_51 FROM clc.clipped_bretagne1 WHERE  
    210210                        substring(code_00 from 1 for 2)='51' 
    211211                        GROUP BY gid) AS waterbodies 
    212212                        on waterbodies.gid =init.gid 
    213         FULL OUTER JOIN (SELECT gid,sum(area) AS seawater_52 FROM clc.clipped_bretagne1 WHERE  
     213        FULL OUTER JOIN (SELECT gid,sum(area) AS marine_water_52 FROM clc.clipped_bretagne1 WHERE  
    214214                        substring(code_00 from 1 for 2)='52' 
    215                         GROUP BY gid) AS seawater 
    216                         on seawater.gid =init.gid); --375 ms 
     215                        GROUP BY gid) AS marine_water 
     216                        on marine_water.gid =init.gid); --375 ms 
     217ALTER TABLE clc.surf_area ADD CONSTRAINT c_pk_gid_surf_area PRIMARY KEY (gid); 
    217218}}} 
    218219{{{ 
     
    227228        r.gid, 
    228229        area/1e6 as catchment_area, 
    229         CASE WHEN urban_11_13 IS NOT NULL THEN urban_11_13/1e6 
    230         ELSE 0 
    231         END AS urban_11_13, 
    232         CASE WHEN green_urban_14 IS NOT NULL THEN green_urban_14/1e6  
    233         ELSE 0 
    234         END AS green_urban_14, 
     230        CASE WHEN artificial_surfaces_11_13 IS NOT NULL THEN artificial_surfaces_11_13/1e6 
     231        ELSE 0 
     232        END AS artificial_surfaces_11_13, 
     233        CASE WHEN artificial_vegetated_14 IS NOT NULL THEN artificial_vegetated_14/1e6  
     234        ELSE 0 
     235        END AS artificial_vegetated_14, 
    235236        CASE WHEN arable_land_21 IS NOT NULL THEN arable_land_21/1e6  
    236237        ELSE 0 
    237238        END AS arable_land_21, 
    238         CASE WHEN plantations_22 IS NOT NULL THEN plantations_22/1e6  
    239         ELSE 0 
    240         END AS plantations_22, 
     239        CASE WHEN permanent_crops_22 IS NOT NULL THEN permanent_crops_22/1e6  
     240        ELSE 0 
     241        END AS permanent_crops_22, 
    241242        CASE WHEN pastures_23 IS NOT NULL THEN pastures_23/1e6  
    242243        ELSE 0 
    243244        END AS pastures_23, 
    244         CASE WHEN crops_natural_24 IS NOT NULL THEN crops_natural_24/1e6 
    245         ELSE 0 
    246         END AS crops_natural_24, 
     245        CASE WHEN heterogeneous_agricultural_24 IS NOT NULL THEN heterogeneous_agricultural_24/1e6 
     246        ELSE 0 
     247        END AS heterogeneous_agricultural_24, 
    247248        CASE WHEN forest_31 IS NOT NULL THEN forest_31/1e6  
    248249        ELSE 0 
     
    254255        ELSE 0 
    255256        END AS wetlands_4, 
    256         CASE WHEN water_51 IS NOT NULL THEN water_51 /1e6  
    257         ELSE 0 
    258         END AS water_51, 
    259         CASE WHEN  seawater_52 IS NOT NULL THEN seawater_52/1e6  
    260         ELSE 0 
    261         END AS seawater_52, 
     257        CASE WHEN inland_waterbodies_51 IS NOT NULL THEN inland_waterbodies_51 /1e6  
     258        ELSE 0 
     259        END AS inland_waterbodies_51, 
     260        CASE WHEN  marine_water_52 IS NOT NULL THEN marine_water_52/1e6  
     261        ELSE 0 
     262        END AS marine_water_52, 
    262263        c.wso1_id, 
    263264        c.the_geom       
     
    274275{{{ 
    275276#!sql 
     277DROP TABLE IF EXISTS clc.surf_area_analyse; 
    276278CREATE TABLE clc.surf_area_analyse AS(  
    277279SELECT  
     
    279281        wso1_id, 
    280282        catchment_area, 
    281         urban_11_13+ 
    282          green_urban_14+ 
     283        artificial_surfaces_11_13+ 
     284         artificial_vegetated_14+ 
    283285         arable_land_21+ 
    284          plantations_22+ 
     286         permanent_crops_22+ 
    285287         pastures_23+ 
    286          crops_natural_24+ 
     288         heterogeneous_agricultural_24+ 
    287289         forest_31+ 
    288290         natural_32_33+ 
    289291         wetlands_4+ 
    290          water_51 + 
    291          seawater_52 as sum_clc_area , 
    292         (urban_11_13+ 
    293          green_urban_14+ 
     292         inland_waterbodies_51 + 
     293         marine_water_52 as sum_clc_area , 
     294        (artificial_surfaces_11_13+ 
     295         artificial_vegetated_14+ 
    294296         arable_land_21+ 
    295          plantations_22+ 
     297         permanent_crops_22+ 
    296298         pastures_23+ 
    297          crops_natural_24+ 
     299         heterogeneous_agricultural_24+ 
    298300         forest_31+ 
    299301         natural_32_33+ 
    300302         wetlands_4+ 
    301          water_51 + 
    302          seawater_52)/catchment_area AS pourc_clc, 
     303         inland_waterbodies_51 + 
     304         marine_water_52)/catchment_area AS pourc_clc, 
    303305         the_geom 
    304306         FROM clc.surf_area1); 
     
    309311CREATE INDEX indexclc00area_analyse ON clc.surf_area_analyse 
    310312  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
     313 
    311314}}} 
    312315