shapely.is_valid_reason

shapely.is_valid_reason#

is_valid_reason(geometry, **kwargs)#

Return a string stating if a geometry is valid and if not, why.

Returns None for missing values.

Parameters:
geometryGeometry or array_like

Geometry or geometries to check. Any geometry type is accepted.

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

is_valid

returns True or False

Examples

>>> import shapely
>>> from shapely import LineString, Polygon
>>> shapely.is_valid_reason(LineString([(0, 0), (1, 1)]))
'Valid Geometry'
>>> shapely.is_valid_reason(Polygon([(0, 0), (1, 1), (1, 2), (1, 1), (0, 0)]))
'Self-intersection[1 2]'
>>> shapely.is_valid_reason(None) is None
True