3

I have a number of XY coordinates and am looking to discern which country each of these are in, who knows a good service/way of doing this?

I am working with MySQL & PHP, not that its really relevant, I am o fey with consuming web services/pages and assume there must be a web-service/page somewhere which will do this, if someone can point me in the right direction that would be awesome.

How do I take: 306458,383136 and turn it into: United Kingdom (for example.)

Appreciate your responses in advance.

Woody Hayday
  • 336
  • 3
  • 8

2 Answers2

2

What you're looking for is called reverse geocoding, and e.g. Google Maps has this functionality: http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding

It works from a Lat/Lon coordinate, and could return even a more precise information than only a country; note that this is only an estimate - in some places, country boundaries are somewhat tangled.

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
0

If you're looking to do this offline, or if Google's/Bing's/whoever's licensing is too strict for you (e.g. you need to do a gazillion of requests per day, or need to present the result in an unorthodox format), it's possible to run your own instance of Nominatim, feed it a data extract from OpenStreetMap (under ODbL, a much more permissive license), and query that.

For example, there's a set of boundaries available at https://wambachers-osm.website/boundaries/ - just the national boundaries, so you wouldn't need to download the entire planet map.

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222