geopandas.GeoSeries.count_interior_rings#

GeoSeries.count_interior_rings()[source]#

Returns a Series containing the count of the number of interior rings in a polygonal geometry.

For non-polygonal geometries, this is always 0.

See also

GeoSeries.count_coordinates

count the number of coordinates in a geometry

GeoSeries.count_geometries

count the number of geometries in a collection

Examples

>>> from shapely.geometry import Polygon, Point
>>> s = geopandas.GeoSeries(
...     [
...         Polygon(
...             [(0, 0), (0, 5), (5, 5), (5, 0)],
...             [[(1, 1), (1, 4), (4, 4), (4, 1)]],
...         ),
...         Polygon(
...             [(0, 0), (0, 5), (5, 5), (5, 0)],
...             [
...                 [(1, 1), (1, 2), (2, 2), (2, 1)],
...                 [(3, 2), (3, 3), (4, 3), (4, 2)],
...             ],
...         ),
...         Point(0, 1),
...     ]
... )
>>> s
0    POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0), (1 1, 1 4,...
1    POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0), (1 1, 1 2,...
2                                          POINT (0 1)
dtype: geometry
>>> s.count_interior_rings()
0    1
1    2
2    0
dtype: int32