dont clean geometry if it would create a multipolygon
This commit is contained in:
parent
edd1af432c
commit
122d7b71f0
1 changed files with 4 additions and 1 deletions
|
@ -50,6 +50,9 @@ def round_coordinates(data):
|
|||
|
||||
|
||||
def clean_geometry(geometry):
|
||||
"""
|
||||
if the given geometry is a Polygon and invalid, try to make it valid if it results in a Polygon (not MultiPolygon)
|
||||
"""
|
||||
if geometry.is_valid:
|
||||
return geometry
|
||||
|
||||
|
@ -58,7 +61,7 @@ def clean_geometry(geometry):
|
|||
for interior in geometry.interiors:
|
||||
p = p.difference(Polygon(list(interior.coords)))
|
||||
|
||||
if p.is_valid:
|
||||
if isinstance(p, Polygon) and p.is_valid:
|
||||
return p
|
||||
|
||||
return geometry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue