我希望通过一条线串拆分一个多多边形(代表一个有岛屿的国家),从而将该县一分为二
from shapely.ops import split
collection_of_polyogns = split(country,line)
此结果是GeometryCollection对象中的一组多边形。如何将结果分组为两个多多边形对象,每个对象都包含各自一半的多边形
更新
问题是: Determine the "left" and "right" side of a split shapely geometry提供了一个很好的解决方案,其中从结果中的每个多边形中提取一个点,以查看它与拆分线串组合时是否形成顺时针或逆时针线串。但是我想用质心代替每个多边形,因为它保证不在分割线上
因此,首先要创建多多边形,然后拆分多边形:
然后,将国家/地区的原始边界绘制为多边形,并使用直线执行相同的分割:
制作两个列表,并在分割的国家多边形上迭代,以检查它们是否位于边界分割多边形的第一个多边形内:
最后,将两个列表指定为两个不同的多多边形:
相关问题 更多 >
编程相关推荐