Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert multipolygon geometry into list

How can I please convert a multipolygon geometry into a list? I tried this:

mycoords=geom.exterior.coords
mycoordslist = list(mycoords)

But I get the error:

AttributeError: 'MultiPolygon' object has no attribute 'exterior'

like image 323
mee Avatar asked Jun 11 '26 23:06

mee


1 Answers

You will have to loop over geometries within your MultiPolygon.

mycoordslist = [list(x.exterior.coords) for x in geom.geoms]

Note that the result is a list of coords lists.

like image 192
martinfleis Avatar answered Jun 14 '26 12:06

martinfleis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!