> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GeoSeries.transform

> Apply a function to geometry coordinates in distributed batches.

Apply a function to geometry coordinates in distributed batches.

*Added in version 2.0.0.*

## Signature

```python theme={"system"}
transform(transformation, include_z=False)
```

## Parameters

<ParamField path="transformation" type="callable" required>
  A function that transforms an (N, 2) or (N, 3) NumPy array of
  float64 coordinates into an array of the same shape and dtype.
  The function must preserve coordinate order and must be serializable
  for execution on Spark workers.
</ParamField>

<ParamField path="include_z" type="bool" default="False">
  If False, discard the third dimension. If True, include the third
  dimension in the coordinates passed to the function. Coordinates of
  2D geometries have NaN in the third column.
</ParamField>

## Returns

<ResponseField name="return" type="GeoSeries">
  Transformed geometries with the original index and CRS. Null and
  empty geometries are preserved.
</ResponseField>

<Note>
  Requires Spark 3.5 or newer and Shapely 2.0 or newer, including on the
  workers. Execution is lazy; exceptions raised by the callback or invalid
  returned arrays surface when Spark evaluates the result.

  Unlike local GeoPandas, the callback receives coordinates from one
  Spark batch at a time, not from the entire GeoSeries. Batch sizes and
  boundaries are unspecified, and Spark may execute the function multiple
  times. Use deterministic, coordinate-wise transformations whose results
  do not depend on batching or mutable state. For example,
  `lambda coords: coords + [1, 2]` is independent of batching, while
  `lambda coords: coords - coords.mean(axis=0)` centers each batch
  separately. Compute global statistics first and pass the resulting
  constants to the callback when a transformation needs them.

  This restriction is a caller responsibility; arbitrary Python callbacks
  cannot be checked for dependence on batch boundaries. The result keeps
  the input CRS; use `to_crs` for CRS-aware reprojection.
</Note>

## Examples

```python theme={"system"}
>>> from shapely.geometry import Point, Polygon
>>> from sedona.spark.geopandas import GeoSeries
>>> s = GeoSeries([Point(0, 0)])
>>> s.transform(lambda coords: coords + 1)
0    POINT (1 1)
dtype: geometry
```

```python theme={"system"}
>>> s = GeoSeries([Polygon([(0, 0), (1, 1), (0, 1)])])
>>> s.transform(lambda coords: coords * [2, 3])
0    POLYGON ((0 0, 2 3, 0 3, 0 0))
dtype: geometry
```

```python theme={"system"}
>>> s = GeoSeries([Point(0, 0, 0)])
>>> s.transform(lambda coords: coords + 1, include_z=True)
0    POINT Z (1 1 1)
dtype: geometry
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.