SatheeshJM
SatheeshJM

Reputation: 3633

Given longitude and latitude, how to find country

If I have a latitude and longitude, how do I find out the country of that location.. If found out about Google Reverse Geocoding, but unfortunately, it requires the service to be used along with Google Maps, which is not my case..

Is there a static database or something which I can refer to? It would be better if I have a static database as opposed to a service..

Upvotes: 0

Views: 3620

Answers (3)

AlexWien
AlexWien

Reputation: 28727

Without a service, it is a lot of work.

First, you need the country polygons with assigned country codes. One country will have on average approx 50.000 vertices.

Then it's a simple point-in-polygon search.

Use a spatial index to limit the country polygon to search. It becomes a bit more difficult if you have to consider enclaves.

Upvotes: 2

Shehabic
Shehabic

Reputation: 6877

You can use Bing Maps Api, it doesn't require displaying maps as far as I know,

http://dev.virtualearth.net/services/v1/geocodeservice/geocodeservice.asmx/ReverseGeocode?latitude=22.98&longitude=35.43637&key=[YOU_KEY]&culture=%22en-us%22&format=json

Upvotes: 2

Related Questions