# List of central coordinates (centroid) for all countries?

I need a list of the central points (centroid) for all countries:

China: lat/long (coordinates of the most central point in China)
France: lat/long (coordinates of the most central point in France)
etc...

This has lots of information on the countries (incl. Centroids), and the possibility to download the data in several formats:

https://worldmap.harvard.edu/data/geonode:country_centroids_az8

You can retrieve this information using R like this:

library(rgeos)
library(rworldmap)

# get world map
wmap <- getMap(resolution="high")

# get centroids
centroids <- gCentroid(wmap, byid=TRUE)

# get a data.frame with centroids
df <- as.data.frame(centroids)

#>                     x         y
#> Aruba       -69.97345  12.51678
#> Afghanistan  66.00845  33.83627
#> Angola       17.53646 -12.29118
#> Anguilla    -63.06082  18.22560
#> Albania      20.05399  41.14258
#> Aland        20.03715  60.20733

# plot
plot(centroids)

You can get country centroids using Python and GeoPandas.

import geopandas as gpd
import pandas as pd

# Access built-in Natural Earth data via GeoPandas

# Get a list (dataframe) of country centroids
centroids = world.centroid
centroid_list = pd.concat([world.name, centroids], axis=1)

# Plot the results
base = world.plot(column = 'name', cmap = 'Blues')
centroids.plot(ax = base, marker = 'o', color = 'red', markersize = 5)

In [1]: centroid_list
Out[1]:
name                                              0
0               Afghanistan  POINT (66.08669022192834 33.85639928169076)
1                    Angola  POINT (17.47057255231345 -12.24586903613316)
2                   Albania  POINT (20.03242643144321 41.14135330604877)
3      United Arab Emirates  POINT (54.20671476159633 23.86863365334761)
4                 Argentina  POINT (-65.17536077114174 -35.44682148949509)
5                   Armenia  POINT (45.00029001101479 40.21660761230144)
6                Antarctica  POINT (20.57100056984261 -80.49198288284349)
... and so on ...

Here's a list that Google provides: