geopandas.GeoSeries.is_valid_reason#
- GeoSeries.is_valid_reason()[来源]#
返回一个
Series字符串,其中包含每个几何体无效的原因。另请参阅
GeoSeries.is_valid检测无效几何图形
GeoSeries.make_valid修复无效的几何图形
示例
一个包含一个无效多边形(交叉自身的蝴蝶结几何图形)和一个缺失几何图形的示例:
>>> 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