Changes between Version 61 and Version 62 of CLC Join
- Timestamp:
- Jun 1, 2010 3:51:49 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CLC Join
v61 v62 154 154 CREATE TABLE clc.surf_area AS ( 155 155 SELECT DISTINCT ON (init.gid) init.gid, 156 urban_11_13,157 green_urban_14,156 artificial_surfaces_11_13, 157 artificial_vegetated_14, 158 158 arable_land_21, 159 p lantations_22,159 permanent_crops_22, 160 160 pastures_23, 161 crops_natural_24,161 heterogeneous_agricultural_24, 162 162 forest_31, 163 163 natural_32_33, 164 164 wetlands_4, 165 water_51 ,166 seawater_52165 inland_waterbodies_51 , 166 marine_water_52 167 167 -- SELECT * 168 168 FROM ( 169 169 SELECT gid from clc.clipped_bretagne1 ) as init 170 FULL OUTER JOIN (SELECT gid,sum(area) AS urban_11_13 FROM clc.clipped_bretagne1 WHERE170 FULL OUTER JOIN (SELECT gid,sum(area) AS artificial_surfaces_11_13 FROM clc.clipped_bretagne1 WHERE 171 171 substring(code_00 from 1 for 2)='11' 172 172 OR substring(code_00 from 1 for 2)='12' 173 173 OR substring(code_00 from 1 for 2)='13' 174 GROUP BY gid) AS urban175 on (init.gid) =( urban.gid)176 FULL OUTER JOIN (SELECT gid,sum(area) AS green_urban_14 FROM clc.clipped_bretagne1 WHERE174 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 177 177 substring(code_00 from 1 for 2)='14' 178 GROUP BY gid) AS green_urban179 on green_urban.gid =init.gid178 GROUP BY gid) AS artificial_vegetated 179 on artificial_vegetated.gid =init.gid 180 180 FULL OUTER JOIN (SELECT gid,sum(area) AS arable_land_21 FROM clc.clipped_bretagne1 WHERE 181 181 substring(code_00 from 1 for 2)='21' 182 182 GROUP BY gid) AS arable_land 183 183 on arable_land.gid =init.gid 184 FULL OUTER JOIN (SELECT gid, sum(area) AS p lantations_22 FROM clc.clipped_bretagne1 WHERE184 FULL OUTER JOIN (SELECT gid, sum(area) AS permanent_crops_22 FROM clc.clipped_bretagne1 WHERE 185 185 substring(code_00 from 1 for 2)='22' 186 GROUP BY gid) AS p lantations187 on p lantations.gid =init.gid186 GROUP BY gid) AS permanent_crops 187 on permanent_crops.gid =init.gid 188 188 FULL OUTER JOIN (SELECT gid,sum(area) AS pastures_23 FROM clc.clipped_bretagne1 WHERE 189 189 substring(code_00 from 1 for 2)='23' 190 190 GROUP BY gid) AS pastures 191 191 on pastures.gid =init.gid 192 FULL OUTER JOIN (SELECT gid, sum(area) AS crops_natural_24 FROM clc.clipped_bretagne1 WHERE192 FULL OUTER JOIN (SELECT gid, sum(area) AS heterogeneous_agricultural_24 FROM clc.clipped_bretagne1 WHERE 193 193 substring(code_00 from 1 for 2)='24' 194 GROUP BY gid) AS crops_natural195 on crops_natural.gid =init.gid194 GROUP BY gid) AS heterogeneous_agricultural 195 on heterogeneous_agricultural.gid =init.gid 196 196 FULL OUTER JOIN (SELECT gid,sum(area) AS forest_31 FROM clc.clipped_bretagne1 WHERE 197 197 substring(code_00 from 1 for 2)='31' … … 207 207 GROUP BY gid) AS wetlands 208 208 on wetlands.gid =init.gid 209 FULL OUTER JOIN (SELECT gid,sum(area) AS water_51 FROM clc.clipped_bretagne1 WHERE209 FULL OUTER JOIN (SELECT gid,sum(area) AS inland_waterbodies_51 FROM clc.clipped_bretagne1 WHERE 210 210 substring(code_00 from 1 for 2)='51' 211 211 GROUP BY gid) AS waterbodies 212 212 on waterbodies.gid =init.gid 213 FULL OUTER JOIN (SELECT gid,sum(area) AS seawater_52 FROM clc.clipped_bretagne1 WHERE213 FULL OUTER JOIN (SELECT gid,sum(area) AS marine_water_52 FROM clc.clipped_bretagne1 WHERE 214 214 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 217 ALTER TABLE clc.surf_area ADD CONSTRAINT c_pk_gid_surf_area PRIMARY KEY (gid); 217 218 }}} 218 219 {{{ … … 227 228 r.gid, 228 229 area/1e6 as catchment_area, 229 CASE WHEN urban_11_13 IS NOT NULL THEN urban_11_13/1e6230 ELSE 0 231 END AS urban_11_13,232 CASE WHEN green_urban_14 IS NOT NULL THEN green_urban_14/1e6233 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, 235 236 CASE WHEN arable_land_21 IS NOT NULL THEN arable_land_21/1e6 236 237 ELSE 0 237 238 END AS arable_land_21, 238 CASE WHEN p lantations_22 IS NOT NULL THEN plantations_22/1e6239 ELSE 0 240 END AS p lantations_22,239 CASE WHEN permanent_crops_22 IS NOT NULL THEN permanent_crops_22/1e6 240 ELSE 0 241 END AS permanent_crops_22, 241 242 CASE WHEN pastures_23 IS NOT NULL THEN pastures_23/1e6 242 243 ELSE 0 243 244 END AS pastures_23, 244 CASE WHEN crops_natural_24 IS NOT NULL THEN crops_natural_24/1e6245 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, 247 248 CASE WHEN forest_31 IS NOT NULL THEN forest_31/1e6 248 249 ELSE 0 … … 254 255 ELSE 0 255 256 END AS wetlands_4, 256 CASE WHEN water_51 IS NOT NULL THEN water_51 /1e6257 ELSE 0 258 END AS water_51,259 CASE WHEN seawater_52 IS NOT NULL THEN seawater_52/1e6260 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, 262 263 c.wso1_id, 263 264 c.the_geom … … 274 275 {{{ 275 276 #!sql 277 DROP TABLE IF EXISTS clc.surf_area_analyse; 276 278 CREATE TABLE clc.surf_area_analyse AS( 277 279 SELECT … … 279 281 wso1_id, 280 282 catchment_area, 281 urban_11_13+282 green_urban_14+283 artificial_surfaces_11_13+ 284 artificial_vegetated_14+ 283 285 arable_land_21+ 284 p lantations_22+286 permanent_crops_22+ 285 287 pastures_23+ 286 crops_natural_24+288 heterogeneous_agricultural_24+ 287 289 forest_31+ 288 290 natural_32_33+ 289 291 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+ 294 296 arable_land_21+ 295 p lantations_22+297 permanent_crops_22+ 296 298 pastures_23+ 297 crops_natural_24+299 heterogeneous_agricultural_24+ 298 300 forest_31+ 299 301 natural_32_33+ 300 302 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, 303 305 the_geom 304 306 FROM clc.surf_area1); … … 309 311 CREATE INDEX indexclc00area_analyse ON clc.surf_area_analyse 310 312 USING GIST ( the_geom GIST_GEOMETRY_OPS ); 313 311 314 }}} 312 315