Skip to content

Instantly share code, notes, and snippets.

@robbibt
Last active April 16, 2022 09:16
Show Gist options
  • Select an option

  • Save robbibt/7639935045a1473c3af5a86ece4273f1 to your computer and use it in GitHub Desktop.

Select an option

Save robbibt/7639935045a1473c3af5a86ece4273f1 to your computer and use it in GitHub Desktop.
Appending GeoPandas data to file
# Author: Claire Krause
# Save the polygons to a shapefile
schema = {'geometry': 'Polygon','properties': {'area': 'str'}}
if os.path.isfile('test.shp'):
with fiona.open('test.shp', "a", crs = from_epsg(3577), driver = 'ESRI Shapefile', schema = schema) as output:
for ix, poly in MergedPolygonsGPD.iterrows():
output.write(({'properties': {'area': poly['area']},'geometry': mapping(shape(poly['geometry']))}))
else:
with fiona.open('test.shp', "w", crs = from_epsg(3577), driver = 'ESRI Shapefile', schema = schema) as output:
for ix, poly in MergedPolygonsGPD.iterrows():
output.write(({'properties': {'area': poly['area']},'geometry': mapping(shape(poly['geometry']))}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment