geopandas.GeoSeries.transform#

GeoSeries.transform(transformation, include_z=False)[source]#

Returns a GeoSeries with the transformation function applied to the geometry coordinates.

Parameters:
transformationCallable

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.

Returns:
GeoSeries

Examples

>>> from shapely import Point, Polygon
>>> s = geopandas.GeoSeries([Point(0, 0)])
>>> s.transform(lambda x: x + 1)
0    POINT (1 1)
dtype: geometry
>>> s = geopandas.GeoSeries([Polygon([(0, 0), (1, 1), (0, 1)])])
>>> s.transform(lambda x: x * [2, 3])
0    POLYGON ((0 0, 2 3, 0 3, 0 0))
dtype: geometry

By default the third dimension is ignored and you need explicitly include it:

>>> s = geopandas.GeoSeries([Point(0, 0, 0)])
>>> s.transform(lambda x: x + 1, include_z=True)
0    POINT Z (1 1 1)
dtype: geometry