init file
This commit is contained in:
parent
090822ccd7
commit
b9e20fe9f8
32
3_AZALEE/tmp/PNE_extract_zh.py
Normal file
32
3_AZALEE/tmp/PNE_extract_zh.py
Normal file
@ -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')
|
||||
Loading…
x
Reference in New Issue
Block a user