init depot renew
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
import geopandas as gpd
|
||||
import requests
|
||||
from os import path
|
||||
import io
|
||||
|
||||
|
||||
def get_zh(geom=None):
|
||||
url = 'https://geonature.cen-isere.fr/geonature/api/exports/api/9?limit=30000&{geo}'
|
||||
if not geom.empty :
|
||||
if geom.crs.srs.lower() != 'epsg:4326':
|
||||
geom.to_crs(4326,inplace=True)
|
||||
if gpd.__version__ >='1.0.1':
|
||||
geometry = 'geometry={geom}'.format(geom=geom.union_all().wkt)
|
||||
else:
|
||||
geometry = 'geometry={geom}'.format(geom=geom.unary_union.wkt)
|
||||
else:
|
||||
geom = ''
|
||||
print(url.format(geo=geometry))
|
||||
r = requests.get(url.format(geo=geometry))
|
||||
if r.status_code == 200:
|
||||
d = r.json()
|
||||
data = d['items']['features']
|
||||
p = [i['properties'] for i in data]
|
||||
g = [i['geometry'] for i in data]
|
||||
df = gpd.GeoDataFrame.from_features(data,crs=4326)
|
||||
|
||||
return df
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
PATH = '/media/cgeier/Disk2/tmp/GEONATURE/ST MARTIN URIAGE'
|
||||
FILE = 'ZH ENS POUR CEN 14102025.gpkg'
|
||||
f = gpd.read_file(path.join(PATH,FILE))
|
||||
df = get_zh(f)
|
||||
|
||||
# NEED GeoPandas >=1.0.1 pour sauvegarder
|
||||
df.to_file(path.join(PATH,'inventaire_zoneshumides_seglieres.gpkg'))
|
||||
Reference in New Issue
Block a user