| 519 | = Projection = |
| 520 | Nous choissions de projeter ensemble les données d'ouvrage et les données de stations de pêche qui sont dans la table observation places. |
| 521 | {{{ |
| 522 | #!sql |
| 523 | ----------------------------------------------------------- |
| 524 | -- Jointure géographique entre les observations et la CCM |
| 525 | ----------------------------------------------------------- |
| 526 | |
| 527 | ------ |
| 528 | -- selection des opérations de belgiques: |
| 529 | ------ |
| 530 | DROP TABLE IF EXISTS belge.observation_places; |
| 531 | create table belge.observation_places as( |
| 532 | select * from dbeel.observation_places where op_gis_systemname='SPW' or op_gis_layername='OBSTACLES'); -- 8751 lignes (563 pour stations et 8188 obstacles) |
| 533 | |
| 534 | DROP TABLE IF EXISTS belge.meuse_operations_ccm_500; |
| 535 | CREATE TABLE belge.meuse_operations_ccm_500 as ( |
| 536 | SELECT distinct on (op_id) op_id, gid, wso1_id, min(distance) as distance, the_geom FROM ( |
| 537 | SELECT op_id, gid , wso1_id, CAST(distance(r.the_geom, s.the_geom) as decimal(15,1)) as distance,s.the_geom |
| 538 | FROM belge.observation_places As s |
| 539 | INNER JOIN ccm21.riversegments r ON ST_DWithin(r.the_geom, s.the_geom,500) --6443 lignes (beaucoup d'exclus sont des obstacles en dehors du CCM) |
| 540 | WHERE s.the_geom IS NOT NULL |
| 541 | ) AS sub |
| 542 | GROUP BY op_id,distance, gid, wso1_id, the_geom |
| 543 | ); |
| 544 | |
| 545 | alter table belge.meuse_operations_ccm_500 add column id serial; |
| 546 | |
| 547 | -- mise à jour de la table geometry_columns |
| 548 | INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") |
| 549 | SELECT '', 'belge', 'meuse_operations_ccm_500', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) |
| 550 | FROM belge.meuse_operations_ccm_500 LIMIT 1; |
| 551 | -- creation d'index, clé primaire, et constraintes qui vont bien |
| 552 | alter table belge.meuse_operations_ccm_500 add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); |
| 553 | alter table belge.meuse_operations_ccm_500 add CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); |
| 554 | alter table belge.meuse_operations_ccm_500 add CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); |
| 555 | alter table belge.meuse_operations_ccm_500 ADD CONSTRAINT pk_id PRIMARY KEY(id); |
| 556 | CREATE INDEX indexstation_ccm_500 ON belge.meuse_operations_ccm_500 |
| 557 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |
| 558 | --select*from belge.meuse_operations_ccm_500 |
| 559 | |
| 560 | ------------------------------------------------------------------------------------ |
| 561 | ------------------------------------------------------------------------------------ |
| 562 | -- selection des opérations de l'ensemble des données de dbeel: |
| 563 | DROP TABLE IF EXISTS dbeel.operations_ccm_500; |
| 564 | CREATE TABLE dbeel.operations_ccm_500 as ( |
| 565 | SELECT distinct on (op_id) op_id, gid, wso1_id, min(distance) as distance, the_geom FROM ( |
| 566 | SELECT op_id, gid , wso1_id, CAST(distance(r.the_geom, s.the_geom) as decimal(15,1)) as distance,s.the_geom |
| 567 | FROM dbeel.observation_places As s |
| 568 | INNER JOIN ccm21.riversegments r ON ST_DWithin(r.the_geom, s.the_geom,500) --76406 observations sur 92286 |
| 569 | WHERE s.the_geom IS NOT NULL |
| 570 | ) AS sub |
| 571 | GROUP BY op_id,distance, gid, wso1_id, the_geom |
| 572 | ); |
| 573 | |
| 574 | alter table dbeel.operations_ccm_500 add column id serial; |
| 575 | |
| 576 | -- mise à jour de la table geometry_columns |
| 577 | INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") |
| 578 | SELECT '', 'dbeel', 'operations_ccm_500', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) |
| 579 | FROM dbeel.operations_ccm_500 LIMIT 1; |
| 580 | -- creation d'index, clé primaire, et constraintes qui vont bien |
| 581 | alter table dbeel.operations_ccm_500 add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); |
| 582 | alter table dbeel.operations_ccm_500 add CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); |
| 583 | alter table dbeel.operations_ccm_500 add CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); |
| 584 | alter table dbeel.operations_ccm_500 ADD CONSTRAINT pk_id PRIMARY KEY(id); |
| 585 | CREATE INDEX indexstation_ccm_500 ON dbeel.operations_ccm_500 |
| 586 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |
| 587 | |
| 588 | ---------------------------------------------------------------------------------------- |
| 589 | ------------------------------------------------------------------------------------------- |
| 590 | }}} |
| 591 | [[Image(source:data/Docs/trac/Meuse/projection_op_france.jpg)]] [[BR]] |
| 592 | [[Image(source:data/Docs/trac/Meuse/projection_op_france_zoom.jpg)]] [[BR]] |
| 593 | [[Image(source:data/Docs/trac/Meuse/projection_op_meuse.jpg)]] [[BR]] |
| 594 | [[Image(source:data/Docs/trac/Meuse/projection_op_meuse_zoom.jpg)]] [[BR]] |