python - Python:如何将 Voronoi 单元扩展到几何边界?
问题描述
我有两个 geopandas 数据框dfMd
和centers
. dfMd
由多边形组成,而centers
由点组成。这里是文件的链接。
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
?
解决方案
推荐阅读
- android - 使用自拍杆在程序中做某事
- python - Pandas 滚动适用于 df,其中根据当前行中的值进行过滤
- django - django 的无限滚动在向下滚动时不加载下一页
- javascript - 单击对象时显示信息的方式
- java - 声明的对象无法使用
- java - java如何在属性中配置注释调度程序fixedDelay
- image - 包含 nanoiis 和 sqlcmd 实用程序的自定义 docker 映像
- c# - 如何将 TimeSpan 舍入到一位数毫秒
- c++ - 指针重新分配和多态
- java - Java 中是否存在与平台无关的代码来调用默认应用程序来查看 PDF、DOCX、JPEG 等文档类型?