geopandas.GeoSeries.count_coordinates#

GeoSeries.count_coordinates()[source]#

Returns a Series containing the count of the number of coordinate pairs in a geometry array.

See also

GeoSeries.get_coordinates

extract coordinates as a DataFrame

Examples

An example of a GeoDataFrame with two line strings, one point and one None value:

>>> from shapely.geometry import Polygon, LineString, Point
>>> s = geopandas.GeoSeries(
...     [
...         LineString([(0, 0), (1, 1), (1, -1), (0, 1)]),
...         LineString([(0, 0), (1, 1), (1, -1)]),
...         Point(0, 0),
...         Polygon([(10, 10), (10, 20), (20, 20), (20, 10), (10, 10)]),
...         None
...     ]
... )
>>> s
0                 LINESTRING (0 0, 1 1, 1 -1, 0 1)
1                      LINESTRING (0 0, 1 1, 1 -1)
2                                      POINT (0 0)
3    POLYGON ((10 10, 10 20, 20 20, 20 10, 10 10))
4                                             None
dtype: geometry
>>> s.count_coordinates()
0    4
1    3
2    1
3    5
4    0
dtype: int64