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.
我对 Python 很陌生,所以这个问题的答案可能很简单,但我到处寻找并尝试了很多,但找不到答案。
使用 Shapely 简化多边形可能会导致一个空多边形。如果多边形为空,我想用一个点替换多边形。可以这样工作的东西:
if mypoly is empty: mypoly = [(0,0)]
鉴于这mypoly是一个匀称的多边形,您可以检查它是否为空,使用is_empty内置于 Shapely 来检查是否为空的。
mypoly
is_empty
from shapely.geometry import Point if mypoly.is_empty: mypoly = Point(0, 0)