We use the GeoDist database from CEPII for distances between countries around the world.

However, doing proper GeoIP load balancing between states in USA, there's a lot of sites offering this functionality, but it does not seem to be an actual database with that information.

Is there an open dataset that contain information like distance between states? If not, is there a good reason that one needs to API one of these sites that have the data?

  • 3
    Define distance between states
    – user4293
    Oct 19, 2016 at 11:54
  • In the GeoDist data set I get the distance in thousand meters. I'm guessing they measure between capitols really. That is fine since I want a nice way to divide all the states between two mirrors, one on the east coast and one on the west. Oct 20, 2016 at 13:53
  • I feel like this would be better answered on the GIS SE. Plugins like NNJoin and MMQGIS can provide the distances between points (state capitals) and polygons (states). For reference: gis.stackexchange.com/questions/28038/… Oct 21, 2016 at 18:32
  • I think this question could be improved by being deleted. Jan 20, 2017 at 5:36

1 Answer 1


Often it doesn't make sense to store (database) and share (API) data that can be easily reproduced, especially when everyone has slightly different requirements.

In your case, to calculate the distance between the US capital cities, you can calculate it with a small piece of code, by reading in an array of capital cities latitude and longitude, and then calculating the distance. Here's an example using Python's geopy library (calculating distance between to points on a sphere is not trivial, details).

from geopy.distance import great_circle

juneau_ak = (58.3019, 134.4197)
honolulu_hi = (21.3069, 157.8583)

print(great_circle(juneau_ak, honolulu_hi).kilometers)

Returns: 4525.33307066 (kilometers)

Since there are only 50, you can either manually create a list of US capital city geo-coordinates, or find something prepared online.

enter image description here

  • Thanks for pointing out the difficulties about calculating the distance. I will probably need to fetch data from an Open API and then use that as source. Oct 27, 2016 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.