shapely.is_valid_reason

shapely.is_valid_reason#

is_valid_reason(geometry, **kwargs)#

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

Parameters:
geometryGeometry or array_like

Any geometry type is accepted. Returns None for missing values.

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

is_valid

returns True or False

Examples

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