I get this error while using cascaded_union
(I have also tried unary_union
which produces the same error):
ValueError: No Shapely geometry can be created from null value
I have validated that my polygons are valid. Initially polyB
isn't valid, but it is converted to a valid polygon using buffer(0)
.
Any idea on what I am doing wrong? Here's my code:
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 to the values for polyA, polyB and pols (after they are confirmed to be valid). I have the following versions installed on my Ubuntu 14.04 server:
- python-shapely 1.3.0
- libgeos 3.4.2
- python 2.7