1
import geopandas as gpd
from pyproj import CRS

I'm working with a lot of shapefiles.

  1. I've checked their geometry to be valid .is_valid.
  2. I have updated to geopandas 0.81 shapely 1.7.0 python 3.6.10
  3. I have reprojected my coordinated systems to projected one geo.to_crs(CRS.from_epsg(31983))

Still, everytime I check the file for a simple geo.head() query, I get the warning from geopandas which is great, but has very scarce documentation...

UserWarning: Only Polygon objects have interior rings. For other geometry types, None is returned. 
"Only Polygon objects have interior rings. For other "
  1. I have searched around quite a lot. Found this #issue here https://github.com/geopandas/geopandas/issues/1331 which is closed and did not help.

  2. In the end, what I think is wrong is that there is at least one interior.ring inside my shape which is not an empty list.

How can I set a specific interiors line to []

And in order to set it automatically, I would also need a test that returns which observations have interior rings.

I'm using PyCharm 2020.2

EDIT You can find the data here: https://github.com/BAFurtado/firms_growth_by_APs/ Download all 5 example.* files (shapefile format)

1
  • The shapefiles are results of census tract dissolved. The warning is making geopandas run really slow. I am guessing the inner rings are lines that were left after dissolve(), even though I used buffer(0.00001). I tried with geopandas 0.7.0. I still get the error. I think that PyCharm 2020.2 checks the object and that is what prompts the warning (see the link github.com/geopandas/geopandas/issues/1331) – B Furtado Aug 4 '20 at 18:06
3

This is not an issue with GeoPandas or your geometries, but with PyCharm. If you do gdf.geometry.interiors on non-polygon geometry, GeoPandas raises this warning. You do not call interiors at any point manually, neither gdf.head() calls it. But PyCharm is trying to be helpful and explores attributes for you, which triggers the warning. There might be a possibility to control this in PyCharm, but there's no way to fix it in GeoPandas, as it is not an issue in GeoPandas itself.

The simple fix could be to ignore the warning.

import warnings
warnings.filterwarnings("ignore", "Only Polygon objects", UserWarning)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.