【发布时间】:2021-04-23 20:23:05
【问题描述】:
我有两个 geopandas 数据框 dfMd 和 centers。 dfMd 由多边形组成,而centers 由点组成。 Here 文件链接。
f,ax=plt.subplots()
dfMd.plot(ax=ax, column='volume')
centers.plot(ax=ax, color='red')
我想生成扩展到整个几何图形的点的Voronoi 缨子。这就是我正在做的事情:
from shapely.geometry import mapping
g = [i for i in centers.geometry]
coords = []
for i in range(0, len(g)):
coords.append(mapping(g[i])["coordinates"]) # for first feature/row
from libpysal.cg.voronoi import voronoi, voronoi_frames
regions, vertices = voronoi(coords)
region_df, point_df = voronoi_frames(coords)
fig, ax = plt.subplots()
region_df.plot(ax=ax, color='white',edgecolor='black', lw=3)
dfMd.plot(ax=ax, column='volume',alpha=0.1)
point_df.plot(ax=ax, color='red')
fig, ax = plt.subplots()
region_df.plot(ax=ax, color='white',edgecolor='black', lw=3)
dfMd.plot(ax=ax, column='volume',alpha=0.1)
point_df.plot(ax=ax, color='red')
如何将Voronoi 区域扩展到我的dfMd 的外部边界?
【问题讨论】: