Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何修改现有的多边形?首先,我想在它的外部添加一个点。
poly = Polygon([(0, 0), (1, 1), (1, 0)])
我一直在寻找这样的东西:
poly.append_at(idx=3, Point(1, -1))
但我找不到任何类似的方法来做到这一点。
从 的外部添加或删除点是没有意义Polygon的,因为无论如何您都想重新计算poly.area,poly.length等。Polygon相反,从旧多边形的坐标创建一个新实例:
Polygon
poly.area
poly.length
coords = poly.exterior.coords[:] coords[1] = (2.0, 6.0) # coordinate to change new_poly = Polygon(coords)
请注意,这不考虑poly.interior.
poly.interior