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 – Jan Doggen Oct 19 '16 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. – user2591197 Oct 20 '16 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/… – Trevor J. Smith Oct 21 '16 at 18:32
  • I think this question could be improved by being deleted. – boulder_ruby Jan 20 '17 at 5:36

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. – user2591197 Oct 27 '16 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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