geopandas.GeoSeries.is_valid_reason#

GeoSeries.is_valid_reason()[source]#

Returns a Series of strings with the reason for invalidity of each geometry.

See also

GeoSeries.is_valid

detect invalid geometries

GeoSeries.make_valid

fix invalid geometries

Examples

An example with one invalid polygon (a bowtie geometry crossing itself) and one missing geometry:

>>> from shapely.geometry import Polygon
>>> s = geopandas.GeoSeries(
...     [
...         Polygon([(0, 0), (1, 1), (0, 1)]),
...         Polygon([(0,0), (1, 1), (1, 0), (0, 1)]),  # bowtie geometry
...         Polygon([(0, 0), (2, 2), (2, 0)]),
...         None
...     ]
... )
>>> s
0         POLYGON ((0 0, 1 1, 0 1, 0 0))
1    POLYGON ((0 0, 1 1, 1 0, 0 1, 0 0))
2         POLYGON ((0 0, 2 2, 2 0, 0 0))
3                                   None
dtype: geometry
>>> s.is_valid_reason()
0    Valid Geometry
1    Self-intersection[0.5 0.5]
2    Valid Geometry
3    None
dtype: object