I have a points shapefile and I want to compute the convex hull of the points using shapely, and output the result as a shapefile using Fiona.
Does anyone know how I can do that?
This is what I have tried:
from shapely.geometry import MultiPoint
from fiona.crs import from_epsg
shape = fiona.open('.cache/town_points/ny_points.shp')
with fiona.open('.cache/mew.shp', 'w', 'ESRI Shapefile', shape.schema.copy(), shape.crs) as output:
for feat in shape:
ch_area = MultiPoint(shape).convex_hull
output.write(feat)
Best Answer
To transform the shapefile geometries to shapely geometries (you can't build a MultiPoligon with a single point as in your solution)
To construct a shapely MultiPoint geometry with all the points of the shapefile
NEW save the resulting shapefile
The resulting geometry is a Polygon therefore