How can I check if a polygon entity is actually a multipolygon? I've tried:
if len(polygon) > 1:
but then get the error:
TypeError: object of type 'Polygon' has no len()
I've tried Nill
, None
and others, nothing worked.
Use the object.geom_type
string (see general attributes and methods).
For example:
if poly.geom_type == 'MultiPolygon':
# do multipolygon things.
elif poly.geom_type == 'Polygon':
# do polygon things.
else:
# raise IOError('Shape is not a polygon.')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With