# shapely.transform#

transform(geometry, transformation, include_z=False)#

Returns a copy of a geometry array with a function applied to its coordinates.

With the default of `include_z=False`, all returned geometries will be two-dimensional; the third dimension will be discarded, if present. When specifying `include_z=True`, the returned geometries preserve the dimensionality of the respective input geometries.

Parameters:
geometryGeometry or array_like
transformationfunction

A function that transforms a (N, 2) or (N, 3) ndarray of float64 to another (N, 2) or (N, 3) ndarray of float64.

include_zbool, default False

If True, include the third dimension in the coordinates array that is passed to the `transformation` function. If a geometry has no third dimension, the z-coordinates passed to the function will be NaN.

Examples

```>>> from shapely import LineString, Point
>>> transform(Point(0, 0), lambda x: x + 1)
<POINT (1 1)>
>>> transform(LineString([(2, 2), (4, 4)]), lambda x: x * [2, 3])
<LINESTRING (4 6, 8 12)>
>>> transform(None, lambda x: x) is None
True
>>> transform([Point(0, 0), None], lambda x: x).tolist()
[<POINT (0 0)>, None]
```

By default, the third dimension is ignored:

```>>> transform(Point(0, 0, 0), lambda x: x + 1)
<POINT (1 1)>
>>> transform(Point(0, 0, 0), lambda x: x + 1, include_z=True)
<POINT Z (1 1 1)>
```