Search code examples
google-mapsmapslatitude-longitudegeocode

How do I discern a country from X/Y Coordinates (or Long/Lat)?


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.


Solution

  • 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.