Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created October 31, 2012 15:25
Show Gist options
  • Save tmcw/3987659 to your computer and use it in GitHub Desktop.
Save tmcw/3987659 to your computer and use it in GitHub Desktop.
GIS with Python, Shapely and Fiona Example 2 - Buffers
from shapely.geometry import mapping, shape
from fiona import collection
with collection("some.shp", "r") as input:
# schema = input.schema.copy()
schema = { 'geometry': 'Polygon', 'properties': { 'name': 'str' } }
with collection(
"some_buffer.shp", "w", "ESRI Shapefile", schema) as output:
for point in input:
output.write({
'properties': {
'name': point['properties']['name']
},
'geometry': mapping(shape(point['geometry']).buffer(5.0))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment