Reputation: 181
Running the command dataframe['geometry'].centroid
a warning is shown:
The column 'geometry' is made up of Multipolygon objects. How can I solve this issue to accurately calculate the centroid of my multipolygon's shapes?
Upvotes: 6
Views: 6370
Reputation: 181
This error could be solved by a projection to flat the surfaces down. The dataset I was using was a GeoDataFrame with a crs value of epsg=4326, as shown in the following screenshot
To accurately calculate the centroid we first need a plane area rather than a geodic one. In my case I'd use the ETRS Lambert Azimuthal Equal Area projection (epsg=3035) to flat up the surface of North Europe (where the city of Milan is located).
As a proof, the plot differs a bit from the original one
Performing again a crs() transformation back to epsg=4326 the projected polygon and centroid can be trasformed again in lat/lon coordinates.
Upvotes: 12