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
if isinstance(geometry, Polygon):
return geometry.buffer(0)
return geometry
评论列表
文章目录