【发布时间】:2019-06-04 18:27:55
【问题描述】:
我在使用cascaded_union 时遇到此错误(我也尝试过unary_union 会产生相同的错误):
ValueError: No Shapely geometry can be created from null value
我已验证我的多边形是有效的。最初polyB 无效,但使用buffer(0) 将其转换为有效多边形。
知道我做错了什么吗?这是我的代码:
from shapely.geometry import Polygon
from shapely.ops import cascaded_union
def combineBorders(a, b):
polyA = Polygon(a)
polyB = Polygon(b)
pols = [polyA, polyB]
for p in pols:
if p.is_valid == False:
p = p.buffer(0)
print(p.is_valid)
True
True
newShape = cascaded_union(pols) # THIS IS WHERE THE ERROR KEEPS SHOWING UP
return newShape
Here is a link 到 polyA、polyB 和 pols 的值(在确认它们有效之后)。我的 Ubuntu 14.04 服务器上安装了以下版本:
- python-shapely 1.3.0
- libgeos 3.4.2
- python 2.7
【问题讨论】: