build_shapes: Update save_to_geojson to new fiona version
This commit is contained in:
parent
8f171396cb
commit
aa24686517
@ -121,12 +121,14 @@ def nuts3(country_shapes):
|
|||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
||||||
def save_to_geojson(s, fn):
|
def save_to_geojson(df, fn):
|
||||||
if os.path.exists(fn):
|
if os.path.exists(fn):
|
||||||
os.unlink(fn)
|
os.unlink(fn)
|
||||||
if isinstance(s, gpd.GeoDataFrame):
|
if not isinstance(df, gpd.GeoDataFrame):
|
||||||
s = s.reset_index()
|
df = gpd.GeoDataFrame(dict(geometry=df))
|
||||||
s.to_file(fn, driver='GeoJSON')
|
df = df.reset_index()
|
||||||
|
schema = {**gpd.io.file.infer_schema(df), 'geometry': 'Unknown'}
|
||||||
|
df.to_file(fn, driver='GeoJSON', schema=schema)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Detect running outside of snakemake and mock snakemake for testing
|
# Detect running outside of snakemake and mock snakemake for testing
|
||||||
|
Loading…
Reference in New Issue
Block a user