Search code examples
pythonshapefilegeopandas

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'


Solution

  • 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.