geopandas.GeoSeries.transform#
- GeoSeries.transform(transformation, include_z=False)[来源]#
返回一个
GeoSeries,对几何坐标应用变换函数。- Parameters:
- transformationCallable
一个将(N, 2)或(N, 3)的float64 ndarray转化为另一个(N, 2)或(N, 3)的float64 ndarray的函数
- include_zbool, default False
如果为True,则在传递给
transformation函数的坐标数组中包括第三维度。如果几何形状没有第三维度,则传递给函数的z坐标将为NaN。
- Returns:
- GeoSeries
示例
>>> 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
默认情况下,第三维度会被忽略,您需要明确地包含它:
>>> s = geopandas.GeoSeries([Point(0, 0, 0)]) >>> s.transform(lambda x: x + 1, include_z=True) 0 POINT Z (1 1 1) dtype: geometry