shapely.force_3d#
- force_3d(geometry, z=0.0, **kwargs)#
Force the dimensionality of a geometry to 3D.
2D geometries will get the provided Z coordinate; Z coordinates of 3D geometries are unchanged (unless they are nan).
Note that for empty geometries, 3D is only supported since GEOS 3.9 and then still only for simple geometries (non-collections).
- Parameters:
- geometryGeometry or array_like
Geometry or geometries to force to 3D.
- zfloat or array_like, default 0.0
The Z coordinate value to set on the geometry.
- **kwargs
See NumPy ufunc docs for other keyword arguments.
Examples
>>> from shapely import LineString, Point >>> force_3d(Point(0, 0), z=3) <POINT Z (0 0 3)> >>> force_3d(Point(0, 0, 0), z=3) <POINT Z (0 0 0)> >>> force_3d(LineString([(0, 0), (0, 1), (1, 1)])) <LINESTRING Z (0 0 0, 0 1 0, 1 1 0)> >>> force_3d(None) is None True