shapely.get_coordinate_dimension

shapely.get_coordinate_dimension#

get_coordinate_dimension(geometry, **kwargs)#

Returns the dimensionality of the coordinates in a geometry (2, 3 or 4).

The return value can be one of the following:

  • Return 2 for geometries with XY coordinate types,

  • Return 3 for XYZ or XYM coordinate types (distinguished by has_z() or has_m()),

  • Return 4 for XYZM coordinate types,

  • Return -1 for missing geometries (None values).

Note that with GEOS < 3.12, if the first Z coordinate equals nan, this function will return 2. Geometries with M coordinates are supported with GEOS >= 3.12.

Parameters:
geometryGeometry or array_like
**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

>>> from shapely import Point
>>> get_coordinate_dimension(Point(0, 0))
2
>>> get_coordinate_dimension(Point(0, 0, 1))
3
>>> get_coordinate_dimension(None)
-1