shapely.is_valid

Contents

shapely.is_valid#

is_valid(geometry, **kwargs)#

Return True if a geometry is well formed.

Returns False 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_reason

Returns the reason in case of invalid.

Examples

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