Python_scripts/5_GEONATURE/GN_ZH/tmp/insert_ddt_2024.py
2025-09-22 10:11:08 +02:00

27 lines
629 B
Python

import geopandas as gpd
from pycen import con_gn, update_to_sql
from sqlalchemy import DateTime
from os import path
PATH = '/home/colas/Documents/9_PROJETS/1_ZH/2024/CARTO/Couches SIG'
FILE = 'ZH_zh DDT 2024_MJ_modif 2025.shp'
df = (gpd.read_file(path.join(PATH, FILE))
.rename(columns={'Code ZH':'code','date':'update_date'})
.rename_geometry('geom')
)
df.geom = df.geom.buffer(0).to_crs(4326)
df['update_author'] = 24 # 24 = Mathieu Juton
update_to_sql(
df[['code','update_author', 'update_date','geom']],
con_gn,
't_zh',
'pr_zh',
'code',
dtype={
'update_date': DateTime
}
)