List of central coordinates (centroid) for all countries?
Frank Donnelly provides a CSV file of country centroids that's based on data taken from the GeoNames Server, but hand curated by Frank. The data was last updated in February 2012.
May 2018
The former source isn't available anymore, here is a newer one, with lots of infos on the countries (incl. Centroids), and possibility to download the data in several formats. https://worldmap.harvard.edu/data/geonode:country_centroids_az8
There's also a similar question over at Stackoverflow: Need a list of all countries in the world, with a longitude and latitude coordinate, which includes a couple of approaches for generating such a list from other data sources.
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)
head(df)
#> 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
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
# 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 ...