Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DanielNobbe opened this issue Jul 4, 2023 · 2 comments

Comments

@DanielNobbe
Copy link

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

@aeturrell
Copy link

I've run into this too, and it'd be great to have a fix!

@LiuSeeker
Copy link

LiuSeeker commented Sep 12, 2023

I can try to fix it. It need a proper test/assertion for a MultiPolygon objects, instead of a so called "Duck test" in line 884 (also appears in line 981 and line 1232)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants