diff --git a/3_AZALEE/tmp/PNE_extract_zh.py b/3_AZALEE/tmp/PNE_extract_zh.py new file mode 100644 index 0000000..e90a31e --- /dev/null +++ b/3_AZALEE/tmp/PNE_extract_zh.py @@ -0,0 +1,32 @@ +from pycen import zh +import geopandas as gpd +import os + +def get_intersected(df1,df2): + is_intersect = df1.intersects(df2.unary_union) + return df1[is_intersect].copy() + +def format_data(df): + istype_date = df.dtypes == 'datetime64[ns]' + is_date = df.columns.str.contains('date|heure',case=False,regex=True) + col_date = df.columns[istype_date|is_date] + df[col_date] = df[col_date].astype(str) + + +if __name__ == "__main__": + + PATH = '/home/colas/Documents/tmp/PNE' + file_pne = 'fwdcoucheszoneshumidesisroises/PNE_aoa.shp' + + zh = zh() + v_zh = zh.v_zoneshumides() + zhp = zh.zh_ponctuelles() + pne = gpd.read_file(os.path.join(PATH,file_pne)) + vzh_pne = get_intersected(v_zh,pne) + zhp_pne = get_intersected(zhp,pne) + + format_data(vzh_pne) + format_data(zhp_pne) + + vzh_pne.drop('old_code',axis=1).to_file(os.path.join(PATH,'PNE_ZH.gpkg'),driver='GPKG',layer='inventaire_zh') + zhp_pne.to_file(os.path.join(PATH,'PNE_ZH.gpkg'),driver='GPKG',layer='zh_ponctuelle') \ No newline at end of file