Skip to content

AttributeError: 'MultiPolygon' object has no attribute 'exterior' / TypeError: 'MultiPolygon' object is not iterable #288

@DanielNobbe

Description

@DanielNobbe

When using geoplot with a geopandas dataframe containing MultiPolygon objects in its geometry field, geoplot fails to correctly iterate over the MultiPolygon, and then treats it as a single Polygon, resulting in errors.
The fault lies in e.g.

for subgeom in geom:

The correct way to iterate over a MultiPolygon is by accessing its geoms attribute, rather than directly iterating over the object.

I am using shapely version 2.0.1, I believe this is the package is what's causing the issue. When downgrading to shapely==1.7.1, the problem is alleviated.

Potential fixes:

  • use the geoms attribute
  • pinning the shapely version

I wouldn't mind making a PR to implement a fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions