geopandas.GeoSeries.force_2d#

GeoSeries.force_2d()[source]#

Forces the dimensionality of a geometry to 2D.

Removes the additional Z coordinate dimension from all geometries.

Returns:
GeoSeries

Examples

>>> from shapely import Polygon, LineString, Point
>>> s = geopandas.GeoSeries(
...     [
...         Point(0.5, 2.5, 0),
...         LineString([(1, 1, 1), (0, 1, 3), (1, 0, 2)]),
...         Polygon([(0, 0, 0), (0, 10, 0), (10, 10, 0)]),
...     ],
... )
>>> s
0                            POINT Z (0.5 2.5 0)
1             LINESTRING Z (1 1 1, 0 1 3, 1 0 2)
2    POLYGON Z ((0 0 0, 0 10 0, 10 10 0, 0 0 0))
dtype: geometry
>>> s.force_2d()
0                      POINT (0.5 2.5)
1           LINESTRING (1 1, 0 1, 1 0)
2    POLYGON ((0 0, 0 10, 10 10, 0 0))
dtype: geometry