This commit is contained in:
Colas Geier 2024-08-20 19:20:09 +02:00
parent 631e1b479f
commit e2751e0628
6 changed files with 0 additions and 5352 deletions

View File

@ -1,207 +0,0 @@
from pycen import con_gn
sql = '''
DROP VIEW IF EXISTS gn_exports.v_synthese_sinp_with_metadata_invertebre;
CREATE VIEW gn_exports.v_synthese_sinp_with_metadata_invertebre AS
WITH af_actors AS (
SELECT cafa.id_acquisition_framework,
json_build_object('type_role',
CASE
WHEN cafa.id_organism IS NOT NULL THEN 'organism'::TEXT
WHEN cafa.id_role IS NOT NULL THEN 'role'::TEXT
ELSE NULL::TEXT
END,
'uuid_actor', coalesce(borg.uuid_organisme, tro.uuid_role),
'cd_nomenclature_actor_role', tn.cd_nomenclature, 'identity',
CASE
WHEN cafa.id_organism IS NOT NULL
THEN json_build_object('organism_name', borg.nom_organisme)
WHEN cafa.id_role IS NOT NULL THEN json_build_object('first_name',
tro.nom_role,
'last_name',
tro.prenom_role) END,
'email', coalesce(borg.email_organisme, tro.email)) AS json_data
FROM gn_meta.cor_acquisition_framework_actor cafa
LEFT JOIN utilisateurs.bib_organismes borg ON cafa.id_organism = borg.id_organisme
LEFT JOIN utilisateurs.t_roles tro ON cafa.id_role = tro.id_role
JOIN ref_nomenclatures.t_nomenclatures tn
ON cafa.id_nomenclature_actor_role = tn.id_nomenclature),
af AS (
SELECT taf.id_acquisition_framework,
jsonb_build_object('uuid', taf.unique_acquisition_framework_id, 'name',
taf.acquisition_framework_name,
'desc', taf.acquisition_framework_desc, 'start_date',
taf.acquisition_framework_start_date, 'end_date',
taf.acquisition_framework_end_date,
'initial_closing_date', taf.initial_closing_date, 'territorial_level',
ntl.cd_nomenclature, 'financing_type', nft.cd_nomenclature, 'target_description',
taf.target_description, 'ecologic_or_geologic_target',
taf.ecologic_or_geologic_target, 'actors',
json_agg(af_actors.json_data)) AS af_data
FROM gn_meta.t_acquisition_frameworks taf
JOIN af_actors ON af_actors.id_acquisition_framework = taf.id_acquisition_framework
LEFT JOIN ref_nomenclatures.t_nomenclatures ntl
ON taf.id_nomenclature_territorial_level = ntl.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures nft
ON taf.id_nomenclature_financing_type = nft.id_nomenclature
GROUP BY taf.id_acquisition_framework, taf.acquisition_framework_name, taf.acquisition_framework_desc,
taf.acquisition_framework_start_date, taf.acquisition_framework_end_date, taf.initial_closing_date,
ntl.cd_nomenclature, nft.cd_nomenclature),
ds_actors AS (
SELECT cda.id_dataset,
json_build_object('type_role',
CASE
WHEN cda.id_organism IS NOT NULL THEN 'organism'::TEXT
WHEN cda.id_role IS NOT NULL THEN 'role'::TEXT
ELSE NULL::TEXT
END, 'uuid_actor', coalesce(borg.uuid_organisme, tro.uuid_role),
'cd_nomenclature_actor_role', tn.cd_nomenclature, 'identity',
CASE
WHEN cda.id_organism IS NOT NULL
THEN json_build_object('organism_name', borg.nom_organisme)
WHEN cda.id_role IS NOT NULL THEN json_build_object('first_name',
tro.nom_role,
'last_name',
tro.prenom_role) END,
'email', coalesce(borg.email_organisme, tro.email)) AS json_data
FROM gn_meta.cor_dataset_actor cda
LEFT JOIN utilisateurs.bib_organismes borg ON cda.id_organism = borg.id_organisme
LEFT JOIN utilisateurs.t_roles tro ON cda.id_role = tro.id_role
JOIN ref_nomenclatures.t_nomenclatures tn
ON cda.id_nomenclature_actor_role = tn.id_nomenclature),
ds AS (SELECT tds.id_dataset,
tds.id_acquisition_framework,
-- tds.additional_data,
jsonb_build_object('uuid', tds.unique_dataset_id, 'name', tds.dataset_name, 'desc', tds.dataset_desc,
'shortname', tds.dataset_shortname, 'data_type', ndt.cd_nomenclature,
'collecting_method', ncm.cd_nomenclature, 'data_origin', ndo.cd_nomenclature,
'dataset_objectif', ndso.cd_nomenclature, 'resource_type', nrt.cd_nomenclature,
'source_status', nss.cd_nomenclature, 'territories', array_agg(DISTINCT
ref_nomenclatures.get_cd_nomenclature(cdt.id_nomenclature_territory)),
'actors', json_agg(ds_actors.json_data)) AS dataset_data
FROM gn_meta.t_datasets tds
JOIN ds_actors ON ds_actors.id_dataset = tds.id_dataset
LEFT JOIN gn_meta.cor_dataset_territory cdt ON cdt.id_dataset = tds.id_dataset
LEFT JOIN ref_nomenclatures.t_nomenclatures ndt
ON tds.id_nomenclature_data_type = ndt.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures ncm
ON tds.id_nomenclature_collecting_method = ncm.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures ndo
ON tds.id_nomenclature_data_origin = ndo.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures ndso
ON tds.id_nomenclature_dataset_objectif = ndso.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures nrt
ON tds.id_nomenclature_resource_type = nrt.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures nss
ON tds.id_nomenclature_source_status = nss.id_nomenclature
GROUP BY tds.id_dataset, tds.id_acquisition_framework, tds.unique_dataset_id, tds.dataset_name,
tds.dataset_desc, tds.dataset_shortname, ndt.cd_nomenclature, ncm.cd_nomenclature,
ndo.cd_nomenclature, ndso.cd_nomenclature, nrt.cd_nomenclature, nss.cd_nomenclature)
SELECT s.id_synthese,
s.entity_source_pk_value AS id_source,
s.unique_id_sinp AS id_perm_sinp,
s.unique_id_sinp_grp AS id_perm_grp_sinp,
s.date_min AS date_debut,
s.date_max AS date_fin,
s.cd_nom,
s.meta_v_taxref AS version_taxref,
s.nom_cite,
s.count_min AS nombre_min,
s.count_max AS nombre_max,
s.altitude_min,
s.altitude_max,
s.depth_min AS profondeur_min,
s.depth_max AS profondeur_max,
s.observers AS observateurs,
s.determiner AS determinateur,
s.validator AS validateur,
s.sample_number_proof AS numero_preuve,
s.digital_proof AS preuve_numerique,
s.non_digital_proof AS preuve_non_numerique,
s.comment_context AS comment_releve,
s.comment_description AS comment_occurrence,
ds.dataset_data AS jdd_data,
af.af_data AS ca_data,
s.reference_biblio,
s.cd_hab AS code_habitat,
h.lb_hab_fr AS habitat,
s.place_name AS nom_lieu,
s.precision,
s.additional_data::TEXT AS donnees_additionnelles,
st_astext(s.the_geom_4326) AS wkt_4326,
n1.cd_nomenclature AS nature_objet_geo,
n2.cd_nomenclature AS type_regroupement,
s.grp_method AS methode_regroupement,
n3.cd_nomenclature AS comportement,
n4.cd_nomenclature AS technique_obs,
n5.cd_nomenclature AS statut_biologique,
n6.cd_nomenclature AS etat_biologique,
n7.cd_nomenclature AS naturalite,
n8.cd_nomenclature AS preuve_existante,
n9.cd_nomenclature AS precision_diffusion,
n10.cd_nomenclature AS stade_vie,
n11.cd_nomenclature AS sexe,
n12.cd_nomenclature AS objet_denombrement,
n13.cd_nomenclature AS type_denombrement,
n14.cd_nomenclature AS niveau_sensibilite,
n15.cd_nomenclature AS statut_observation,
n16.cd_nomenclature AS floutage_dee,
n17.cd_nomenclature AS statut_source,
n18.cd_nomenclature AS type_info_geo,
n19.cd_nomenclature AS methode_determination,
n20.cd_nomenclature AS statut_validation,
coalesce(s.meta_update_date, s.meta_create_date) AS derniere_action
FROM gn_synthese.synthese s
JOIN ds ON ds.id_dataset = s.id_dataset
JOIN af ON ds.id_acquisition_framework = af.id_acquisition_framework
LEFT JOIN ref_habitats.habref h ON h.cd_hab = s.cd_hab
LEFT JOIN ref_nomenclatures.t_nomenclatures n1 ON s.id_nomenclature_geo_object_nature = n1.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n2 ON s.id_nomenclature_grp_typ = n2.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n3 ON s.id_nomenclature_behaviour = n3.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n4 ON s.id_nomenclature_obs_technique = n4.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n5 ON s.id_nomenclature_bio_status = n5.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n6 ON s.id_nomenclature_bio_condition = n6.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n7 ON s.id_nomenclature_naturalness = n7.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n8 ON s.id_nomenclature_exist_proof = n8.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n9 ON s.id_nomenclature_diffusion_level = n9.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n10 ON s.id_nomenclature_life_stage = n10.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n11 ON s.id_nomenclature_sex = n11.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n12 ON s.id_nomenclature_obj_count = n12.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n13 ON s.id_nomenclature_type_count = n13.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n14 ON s.id_nomenclature_sensitivity = n14.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n15 ON s.id_nomenclature_observation_status = n15.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n16 ON s.id_nomenclature_blurring = n16.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n17 ON s.id_nomenclature_source_status = n17.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n18 ON s.id_nomenclature_info_geo_type = n18.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n19 ON s.id_nomenclature_determination_method = n19.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n20 ON s.id_nomenclature_valid_status = n20.id_nomenclature
JOIN taxonomie.taxref t ON t.cd_nom = s.cd_nom
JOIN gn_synthese.t_sources ts ON ts.id_source = s.id_source
WHERE t.regne = 'Animalia'
AND t.phylum <> 'Chordata'
-- exclision CA ([SICEN] Données anciennes,[TEST] : migration sicen,[SICEN] Hors Etude)
AND ds.id_acquisition_framework NOT IN (53,66,1,2,6)
-- exclision CA (`Gestion de l'Espace Naturel Sensible du Méandre des Oves`, `Gestion de la Réserve Naturelle Nationale de l'Ile de la Platière`, `Gestion des Natura 2000 FR 8201749 « Milieux alluviaux et aquatiques de lÎle de la Platière » et FR 8212012 « Île de la Platière »`, `RNN Platière`
--AND (ts.id_module = 7 AND ds.id_acquisition_framework IN (7,38,39,42,44,45,46,48,55,57,58,60)
AND (
unaccent(observers) LIKE ANY (array['%%Conservatoire d%%Espaces Naturels Isere%%', '%%Conservatoire d%%Espaces Naturels d%%Isere%%', '%%CEN Isere%%', '%%Association des Amis de l%%Ile de la Platiere%%'])
OR observers NOT LIKE '%%(%%)%%'
)
AND unaccent(observers) NOT LIKE ALL(array[
'%%Sympetrum%%','%%Departement%%','%%Rhone%%','%%Oxalis%%',
'%%LPO%%','%%GRPLS%%','%%Parvi%%','%%CD Isere%%','%%CBNA%%',
'%%Flavia%%','%%Gentiana%%','%%region%%','%%Personnel%%','%%Independant%%'
])
AND observers NOT IN ('', 'Benoit Dodelin',', ')
AND ds.id_dataset NOT IN (185,377,236)
-- exclision JDD `Observations opportunistes du CEN Isère importé depuis Faune Isère`
-- statut_validation = 'Certain - très probable'
-- AND n20.cd_nomenclature = '1'
ORDER BY s.id_synthese;
'''
with con_gn.begin() as cnx:
cnx.execute(sql)

View File

@ -1,207 +0,0 @@
from pycen import con_gn
sql = '''
DROP VIEW IF EXISTS gn_exports.v_synthese_sinp_with_metadata_vertebre;
CREATE VIEW gn_exports.v_synthese_sinp_with_metadata_vertebre AS
WITH af_actors AS (
SELECT cafa.id_acquisition_framework,
json_build_object('type_role',
CASE
WHEN cafa.id_organism IS NOT NULL THEN 'organism'::TEXT
WHEN cafa.id_role IS NOT NULL THEN 'role'::TEXT
ELSE NULL::TEXT
END,
'uuid_actor', coalesce(borg.uuid_organisme, tro.uuid_role),
'cd_nomenclature_actor_role', tn.cd_nomenclature, 'identity',
CASE
WHEN cafa.id_organism IS NOT NULL
THEN json_build_object('organism_name', borg.nom_organisme)
WHEN cafa.id_role IS NOT NULL THEN json_build_object('first_name',
tro.nom_role,
'last_name',
tro.prenom_role) END,
'email', coalesce(borg.email_organisme, tro.email)) AS json_data
FROM gn_meta.cor_acquisition_framework_actor cafa
LEFT JOIN utilisateurs.bib_organismes borg ON cafa.id_organism = borg.id_organisme
LEFT JOIN utilisateurs.t_roles tro ON cafa.id_role = tro.id_role
JOIN ref_nomenclatures.t_nomenclatures tn
ON cafa.id_nomenclature_actor_role = tn.id_nomenclature),
af AS (
SELECT taf.id_acquisition_framework,
jsonb_build_object('uuid', taf.unique_acquisition_framework_id, 'name',
taf.acquisition_framework_name,
'desc', taf.acquisition_framework_desc, 'start_date',
taf.acquisition_framework_start_date, 'end_date',
taf.acquisition_framework_end_date,
'initial_closing_date', taf.initial_closing_date, 'territorial_level',
ntl.cd_nomenclature, 'financing_type', nft.cd_nomenclature, 'target_description',
taf.target_description, 'ecologic_or_geologic_target',
taf.ecologic_or_geologic_target, 'actors',
json_agg(af_actors.json_data)) AS af_data
FROM gn_meta.t_acquisition_frameworks taf
JOIN af_actors ON af_actors.id_acquisition_framework = taf.id_acquisition_framework
LEFT JOIN ref_nomenclatures.t_nomenclatures ntl
ON taf.id_nomenclature_territorial_level = ntl.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures nft
ON taf.id_nomenclature_financing_type = nft.id_nomenclature
GROUP BY taf.id_acquisition_framework, taf.acquisition_framework_name, taf.acquisition_framework_desc,
taf.acquisition_framework_start_date, taf.acquisition_framework_end_date, taf.initial_closing_date,
ntl.cd_nomenclature, nft.cd_nomenclature),
ds_actors AS (
SELECT cda.id_dataset,
json_build_object('type_role',
CASE
WHEN cda.id_organism IS NOT NULL THEN 'organism'::TEXT
WHEN cda.id_role IS NOT NULL THEN 'role'::TEXT
ELSE NULL::TEXT
END, 'uuid_actor', coalesce(borg.uuid_organisme, tro.uuid_role),
'cd_nomenclature_actor_role', tn.cd_nomenclature, 'identity',
CASE
WHEN cda.id_organism IS NOT NULL
THEN json_build_object('organism_name', borg.nom_organisme)
WHEN cda.id_role IS NOT NULL THEN json_build_object('first_name',
tro.nom_role,
'last_name',
tro.prenom_role) END,
'email', coalesce(borg.email_organisme, tro.email)) AS json_data
FROM gn_meta.cor_dataset_actor cda
LEFT JOIN utilisateurs.bib_organismes borg ON cda.id_organism = borg.id_organisme
LEFT JOIN utilisateurs.t_roles tro ON cda.id_role = tro.id_role
JOIN ref_nomenclatures.t_nomenclatures tn
ON cda.id_nomenclature_actor_role = tn.id_nomenclature),
ds AS (SELECT tds.id_dataset,
tds.id_acquisition_framework,
-- tds.additional_data,
jsonb_build_object('uuid', tds.unique_dataset_id, 'name', tds.dataset_name, 'desc', tds.dataset_desc,
'shortname', tds.dataset_shortname, 'data_type', ndt.cd_nomenclature,
'collecting_method', ncm.cd_nomenclature, 'data_origin', ndo.cd_nomenclature,
'dataset_objectif', ndso.cd_nomenclature, 'resource_type', nrt.cd_nomenclature,
'source_status', nss.cd_nomenclature, 'territories', array_agg(DISTINCT
ref_nomenclatures.get_cd_nomenclature(cdt.id_nomenclature_territory)),
'actors', json_agg(ds_actors.json_data)) AS dataset_data
FROM gn_meta.t_datasets tds
JOIN ds_actors ON ds_actors.id_dataset = tds.id_dataset
LEFT JOIN gn_meta.cor_dataset_territory cdt ON cdt.id_dataset = tds.id_dataset
LEFT JOIN ref_nomenclatures.t_nomenclatures ndt
ON tds.id_nomenclature_data_type = ndt.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures ncm
ON tds.id_nomenclature_collecting_method = ncm.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures ndo
ON tds.id_nomenclature_data_origin = ndo.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures ndso
ON tds.id_nomenclature_dataset_objectif = ndso.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures nrt
ON tds.id_nomenclature_resource_type = nrt.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures nss
ON tds.id_nomenclature_source_status = nss.id_nomenclature
GROUP BY tds.id_dataset, tds.id_acquisition_framework, tds.unique_dataset_id, tds.dataset_name,
tds.dataset_desc, tds.dataset_shortname, ndt.cd_nomenclature, ncm.cd_nomenclature,
ndo.cd_nomenclature, ndso.cd_nomenclature, nrt.cd_nomenclature, nss.cd_nomenclature)
SELECT s.id_synthese,
s.entity_source_pk_value AS id_source,
s.unique_id_sinp AS id_perm_sinp,
s.unique_id_sinp_grp AS id_perm_grp_sinp,
s.date_min AS date_debut,
s.date_max AS date_fin,
s.cd_nom,
s.meta_v_taxref AS version_taxref,
s.nom_cite,
s.count_min AS nombre_min,
s.count_max AS nombre_max,
s.altitude_min,
s.altitude_max,
s.depth_min AS profondeur_min,
s.depth_max AS profondeur_max,
s.observers AS observateurs,
s.determiner AS determinateur,
s.validator AS validateur,
s.sample_number_proof AS numero_preuve,
s.digital_proof AS preuve_numerique,
s.non_digital_proof AS preuve_non_numerique,
s.comment_context AS comment_releve,
s.comment_description AS comment_occurrence,
ds.dataset_data AS jdd_data,
af.af_data AS ca_data,
s.reference_biblio,
s.cd_hab AS code_habitat,
h.lb_hab_fr AS habitat,
s.place_name AS nom_lieu,
s.precision,
s.additional_data::TEXT AS donnees_additionnelles,
st_astext(s.the_geom_4326) AS wkt_4326,
n1.cd_nomenclature AS nature_objet_geo,
n2.cd_nomenclature AS type_regroupement,
s.grp_method AS methode_regroupement,
n3.cd_nomenclature AS comportement,
n4.cd_nomenclature AS technique_obs,
n5.cd_nomenclature AS statut_biologique,
n6.cd_nomenclature AS etat_biologique,
n7.cd_nomenclature AS naturalite,
n8.cd_nomenclature AS preuve_existante,
n9.cd_nomenclature AS precision_diffusion,
n10.cd_nomenclature AS stade_vie,
n11.cd_nomenclature AS sexe,
n12.cd_nomenclature AS objet_denombrement,
n13.cd_nomenclature AS type_denombrement,
n14.cd_nomenclature AS niveau_sensibilite,
n15.cd_nomenclature AS statut_observation,
n16.cd_nomenclature AS floutage_dee,
n17.cd_nomenclature AS statut_source,
n18.cd_nomenclature AS type_info_geo,
n19.cd_nomenclature AS methode_determination,
n20.cd_nomenclature AS statut_validation,
coalesce(s.meta_update_date, s.meta_create_date) AS derniere_action
FROM gn_synthese.synthese s
JOIN ds ON ds.id_dataset = s.id_dataset
JOIN af ON ds.id_acquisition_framework = af.id_acquisition_framework
LEFT JOIN ref_habitats.habref h ON h.cd_hab = s.cd_hab
LEFT JOIN ref_nomenclatures.t_nomenclatures n1 ON s.id_nomenclature_geo_object_nature = n1.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n2 ON s.id_nomenclature_grp_typ = n2.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n3 ON s.id_nomenclature_behaviour = n3.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n4 ON s.id_nomenclature_obs_technique = n4.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n5 ON s.id_nomenclature_bio_status = n5.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n6 ON s.id_nomenclature_bio_condition = n6.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n7 ON s.id_nomenclature_naturalness = n7.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n8 ON s.id_nomenclature_exist_proof = n8.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n9 ON s.id_nomenclature_diffusion_level = n9.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n10 ON s.id_nomenclature_life_stage = n10.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n11 ON s.id_nomenclature_sex = n11.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n12 ON s.id_nomenclature_obj_count = n12.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n13 ON s.id_nomenclature_type_count = n13.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n14 ON s.id_nomenclature_sensitivity = n14.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n15 ON s.id_nomenclature_observation_status = n15.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n16 ON s.id_nomenclature_blurring = n16.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n17 ON s.id_nomenclature_source_status = n17.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n18 ON s.id_nomenclature_info_geo_type = n18.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n19 ON s.id_nomenclature_determination_method = n19.id_nomenclature
LEFT JOIN ref_nomenclatures.t_nomenclatures n20 ON s.id_nomenclature_valid_status = n20.id_nomenclature
JOIN taxonomie.taxref t ON t.cd_nom = s.cd_nom
JOIN gn_synthese.t_sources ts ON ts.id_source = s.id_source
WHERE t.regne = 'Animalia'
AND t.phylum = 'Chordata'
-- exclision CA ([SICEN] Données anciennes,[TEST] : migration sicen,[SICEN] Hors Etude)
AND ds.id_acquisition_framework NOT IN (53,65,66,1,2,6)
-- exclision JDD `Observations opportunistes du CEN Isère importé depuis Faune Isère`
AND ds.id_dataset NOT IN (185,377,236)
-- exclision CA (`Gestion de l'Espace Naturel Sensible du Méandre des Oves`, `Gestion de la Réserve Naturelle Nationale de l'Ile de la Platière`, `Gestion des Natura 2000 FR 8201749 « Milieux alluviaux et aquatiques de lÎle de la Platière » et FR 8212012 « Île de la Platière »`, `RNN Platière`
--AND (ts.id_module = 7 AND ds.id_acquisition_framework IN (7,38,39,42,44,45,46,48,55,57,58,60)
AND (
unaccent(observers) LIKE ANY (array['%%Conservatoire d%%Espaces Naturels Isere%%', '%%Conservatoire d%%Espaces Naturels d%%Isere%%', '%%CEN Isere%%', '%%Association des Amis de l%%Ile de la Platiere%%'])
OR observers NOT LIKE '%%(%%)%%'
)
AND unaccent(observers) NOT LIKE ALL(array[
'%%Sympetrum%%','%%Departement%%','%%Rhone%%','%%Oxalis%%',
'%%LPO%%','%%GRPLS%%','%%Parvi%%','%%CD Isere%%','%%Personnel%%','%%Independant%%'
'%%DELOCHE Denis%%'
])
AND observers NOT IN ('', 'Benoit Dodelin',', ')
-- statut_validation = 'Certain - très probable'
-- AND n20.cd_nomenclature = '1'
ORDER BY s.id_synthese;
'''
with con_gn.begin() as cnx:
cnx.execute(sql)

View File

@ -1,58 +0,0 @@
# PGSZH
Script de calcul d'indices caratérisants les zones humides d'un territoire.
## Install
pip install git+https://framagit.org/cen-colas/pycen.git
## Critères concidérés
- Fonctions :
- Fonctions biologiques et écologiques :
- **znieff_1 :** Calcul la présence/absence des zones humides sur des ZNIEFF1 par intersection. (Présence 2 / Absence 0)
- **redi :** Calcul la capacité de déplacement de la faune du réseau écologique départemental de l'Isère (REDI) par intersection. Utilisation d'un buffer de 100m (Présence 2 / Absence 0)
- **fct_bio :** Dans le cas où un zone humide n'intersecte pas une ZNIEFF1, attribution d'un poids à chaque zone humide pour ses fonctions Biologiques et Ecologiques décritent dans les inventaires "zones humides".
(Fonction 1 / Multi-fonctions 2)
- **fct_hab :** Attribution d'un poids à chaque zone humide en fonction du type d'habitat décrit dans les inventaires "zones humides". ('prioritaire|très rare' 2)
- **fct_esppatri :** Attribution d'un poids à chaque zone humide en fonction des espèces protégées (DH|PR|DO|LR|PN|LRR|LRN|LRM|LRF|LRD|LRE) décritent dans les inventaires "zones humides". (0 < nb esp < 3 : 0.5 / nb esp >= 3 : 1)
- Fonctions hydrologiques :
- **zone_inond :** Calcul la présence/absence des zones humides sur des zones inondables par intersection (Présence 1 / Absence 0).
- **eabf :** Calcul de l'espace alluvial de bon fonctionnement (EABF)
ou de fond de vallée par intersection (Présence 1 / Absence 0).
- **dist_reso_hydro :** Si la zone humide ne possède pas d'espace
alluviale de bon fonctionnement d'après la fonction "eabf()", calcul la distance au réseau hydrographique linéaire (le plus proche). Attribution d'un poids en fonction de la distance. Si la zone ne possède pas d'eabf et ne semble pas à proximité d'un réseau hydrique, recherche de la présence d'un cours d'eau dans la base de données zones humes. (_> 50m_ : 0 / _]10 m 50 m]_ : 0.5 / _<= 10m_ : 1)
- **reghydro_out :** Pour chaque zone humide, en cas de distance
au réseau hydrographique linéaire > 50 et d'absence d'espace alluviale de bon fonctionnement, recherche dans la base de données des zones humides si une sortie d'eau "Cours d'eau"est définie. Attribution d'un poids en fonction (Si "Cours d'eau" : 1).
- **connex_molasse :** Attribution d'un poids à chaque zone humide en fonction de sa connexion avérée à la molasse ou non (Présence 1 / Absence 0).
- **idpr :** Calcul de l'Indice de Développement et de Persistance des Réseaux. Calcul réalisé dans le cas où connex_molasse = 0 (Si recouvrement > 25% : 1).
- **fct_hydro :** Attribution d'un poids à chaque zone humide en fonction du nombre de rôles hydro-biologiques à caractères hydrauliques et hydrologiques qu'elle remplie (Fonction 0.5 / Multi-fonctions 1).
- **zse_zsnea :** Attribution d'un poids à chaque zone humide en fonction de sont appartenance à une zone de sauvegarde exploitée actuelle (zse) ou future (zsnea) (Présence 1 / Absence 0).
- Fonctions physiques et biochimiques :
- **perim_captage :** Identification de la présence/absence de zones de captages à proximité des zones humides par intersection (Si intersection : 2).
- **fct_hydrobio :** Attribution d'un poids à chaque zone humide en fonction du nombre de rôles hydro-biologiques à caractères physiques et biochimiques qu'elle remplie (Fonction 1 / Multi-fonctions 2).
- **occup_sol :** Pour chaque zone humide, identification de la nature d'occupation du sol et de sa surface de recouvrement global (). Déduction de la surface d'espace naturel concernée par les zonnages. Attribution d'un poids en fonction de la surface de recouverte (_[ 25% ; 50% [_ : 1 / _[ 50% ; 75% [_ : 1.5 / _[ 75% ; 100% ]_ : 2).
- Criètes « multi-fonctions » :
- **surface :** Calcul de la surface totale des zones humides. Attribution d'un poid en fonction du résultat ( _[ 1ha ; 20ha [_ : 0.5 / _[ 20ha ; 100ha [_ : 1 / _>= 100ha_ : 1.5).
- **pente :** Calcul de la pente moyenne des zones humides via le MNT. Attribution d'un poid en fonction du résultat (moy(pente) < 5% : 1).
- **dir_exp :** Ajout d'un champ dir_exp dans le tableau de sortie qui sera à remplir manuellement par celui-ci.
- Pressions :
- Directes :
- **artif_directe :** Récupération des résultats des pressions directes d'artificialisation Rhoméo I12. Application de la discrimination de Jenks pour catégoriser les résultats en 3 classes [0, 0.5, 1].
- **urbani_directe :** Récupération des résultats des pressions directes d'urbanisation Rhoméo I12. Application de la discrimination de Jenks pour catégoriser les résultats en 4 classes [0, 0.5, 1, 1.5].
- **pressAgri_directe :** Récupération des résultats des pressions directes agricoles Rhoméo I13. Application de la discrimination de Jenks pour catégoriser les résultats en 3 classes [0, 0.5, 1].
- **projet_plu_U :** Intersections des zones relevant du projet d'Urbanisme (PLU) avec les polygones de l'étude. Considération du champs Typezone == 'U'. Attribution des points en cas d'intersections (Présence 1 / Absence 0).
- **conflit_redi :** Intersections des zones de conflits redi (Points, Lignes) avec les polygones de l'étude. Utilistaion d'un buffer de 100m (Présence 2 / Absence 0).
- **prelev_eau :** Identification da la proximité des zones humides avec des sources de captages. Application d'un buffer de 50m. Identification par intersection (Présence 1 / Absence 0).
- **icpe :** Identification da la proximité des zones humides avec des installations classés.Application d'un buffer de 500m. Identification par intersection (Présence 1 / Absence 0).
- **ouvrage :** Identification da la présence d'ouvrages et de dépôts au sein des zones humides. Identification par intersection (Présence 1 / Absence 0).
- **vulnerabilite :** Identification da la proximité des zones humides avec des espèces exotiques envahissantes. Application d'un buffer de 100m. Identification par intersection (Présence 1 / Absence 0).
- Indirectes :
- **artif_indir :** Récupération des résultats des pressions indirectes d'artificialisation Rhoméo I12. Application de la discrimination de Jenks pour catégoriser les résultats en 3 classes [0, 0.5, 1].
- **urbani_indir :** Récupération des résultats des pressions indirectes d'urbanisation Rhoméo I12. Application de la discrimination de Jenks pour catégoriser les résultats en 4 classes [0, 0.5, 1, 1.5].
- **pressAgri_indir :** Récupération des résultats des pressions indirectes agricoles Rhoméo I13. Application de la discrimination de Jenks pour catégoriser les résultats en 3 classes [0, 0.5, 1].
- **projet_plu_AU :** Intersections des zones relevant du projet d'Urbanisme (PLU) avec les polygones de l'étude. Considération du champs Typezone == 'AU'. Attribution des points en cas d'intersections (Présence 1 / Absence 0).
- **projet_scot :** En cas d'absence de PLU, recherche d'espaces de développements potentiels au alentours des sites (SCOT). Attribution des points en cas d'intersections (Présence 1 / Absence 0).

View File

@ -1,31 +0,0 @@
from os.path import join
from os import listdir
import geopandas as gpd
SRV = '/media/colas/SRV/FICHIERS'
PATH = 'OUTILS/CARTOGRAPHIE/ESPACE DE TRAVAIL/ETUDES/PGSZH_Belledonne/Pressions/PLU'
DICT_COLS = {
'TYPESECT':'TYPEZONE'
}
KEEP_ZONE = ['U','AU','AUs','AUc']
DF = gpd.GeoDataFrame()
for f in listdir(join(SRV,PATH)):
if f[-3:] != 'shp' : pass
else:
df = gpd.read_file(join(SRV,PATH,f))
df.columns = df.columns.str.upper()
df.rename(columns=DICT_COLS, inplace=True)
DF['SOURCE'] = f
print(df.TYPEZONE.unique())
tmp = df[df.TYPEZONE.isin(KEEP_ZONE)]
DF = gpd.pd.concat([DF,tmp])
DF.set_geometry('GEOMETRY',inplace=True)
DF.rename_geometry('geom', inplace=True)
DF.set_crs(2154,inplace=True)
DF.to_file(join(SRV,PATH,'COUCHES_AGREGEES','FILTREZONE_URBA_U&AU.gpkg'),options={'OVERWRITE=YES'})
DF.to_file(join('~/Documents/tmp','FILTREZONE_URBA_U&AU.gpkg'))

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff