Cotryk
Cotryk

Reputation: 11

How to get Centroid in GeoPandas

Centroid in Geopandas

I have two location so I want get centroid from geopandas by python? How I do it?

Upvotes: 1

Views: 8484

Answers (1)

Thomas
Thomas

Reputation: 10055

You can use geopandas.GeoSeries.centroid:

import geopandas as gpd

df = gpd.read_file("polygons.shp")
df["centroid"] = df["geometry"].centroid
df

See also shapely's documentation: object.centroid.

Upvotes: 9

Related Questions