shapely.get_dimensions#

get_dimensions(geometry, **kwargs)#

Returns the inherent dimensionality of a geometry.

The inherent dimension is 0 for points, 1 for linestrings and linearrings, and 2 for polygons. For geometrycollections it is the max of the containing elements. Empty collections and None values return -1.

Parameters
geometryGeometry or array_like
**kwargs

For other keyword-only arguments, see the NumPy ufunc docs.

Examples

>>> from shapely import GeometryCollection, Point, Polygon
>>> point = Point(0, 0)
>>> get_dimensions(point)
0
>>> polygon = Polygon([(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)])
>>> get_dimensions(polygon)
2
>>> get_dimensions(GeometryCollection([point, polygon]))
2
>>> get_dimensions(GeometryCollection([]))
-1
>>> get_dimensions(None)
-1