def generate_voronoi(geoseries_polygons):
"""Generate Voronoi polygons from polygon edges
:param geoseries_polygons: GeoSeries of raw polygons
:return:
"""
edges = geoseries_polygons.unary_union.boundary
pnts = points_along_boundaries(edges, 0.75)
cent = pnts.centroid
tpnts = translate(pnts, -cent.x, -cent.y)
vor = Voronoi(tpnts)
polys = []
for region in vor.regions:
if len(region) > 0 and all([i > 0 for i in region]):
polys.append(Polygon([vor.vertices[i] for i in region]))
gs_vor = geopandas.GeoSeries(polys)
t_gs_vor = gs_vor.translate(cent.x, cent.y)
t_gs_vor.crs = geoseries_polygons.crs
return t_gs_vor, pnts
substrate_raster.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录