shapely.is_valid

Contents

shapely.is_valid#

is_valid(geometry, **kwargs)#

Returns True if a geometry is well formed.

Parameters:
geometryGeometry or array_like

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

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

is_valid_reason

Returns the reason in case of invalid.

Examples

>>> from shapely import GeometryCollection, LineString, Polygon
>>> is_valid(LineString([(0, 0), (1, 1)]))
True
>>> is_valid(Polygon([(0, 0), (1, 1), (1, 2), (1, 1), (0, 0)]))
False
>>> is_valid(GeometryCollection())
True
>>> is_valid(None)
False