3

Is there a database that I can query for the neighbors of each country?

geonames.org has this info, however, it defines neighborhood formally by having a land border. This creates 2 problems:

  • Useless positives, e.g., according to Geonames, US is a neighbor of Cuba because of Guantanamo Bay.
  • Not quite correct negatives, e.g., while Australia has no land borders, many people would agree that it's a "neighbor" of New Zealand.
2
  • 5
    If you consider Australia a neighbour with New Zealand, but US not a neighbour with Cuba, how do you define neighbours? The US is much closer to Cuba than Australia is to New Zealand.
    – gerrit
    Jul 23, 2014 at 18:48
  • 1
    It would be difficult and in my opinion impossible to have a decent answer, since you have not defined the term neighborhood well. Having a land border is an example. Maybe using a fixed distance for sea borders or anything?
    – Tasos
    Jul 23, 2014 at 19:44

1 Answer 1

5

The Factbook includes a land border entry, for example, the entry for Burkina Faso reads:

3,193 km - Benin 306 km, Cote d'Ivoire 584 km, Ghana 549 km, Mali 1,000 km, Niger 628 km, Togo 126 km

You can get all the data in the public domain in JSON from openmundi/factbook.json for example. Burkina Faso example in JSON:

"land_boundaries": { "total": "3,193 km", "border_countries": "Benin 306 km, Cote d'Ivoire 584 km, Ghana 549 km, Mali 1,000 km, Niger 628 km, Togo 126 km" }

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.