views:

420

answers:

1

Is there an easy way to determine a point's region in the world based on it's latitude and longitude?

I have an entry form that a user enters in their address (city, state, and country). I then geocode this into a point that I can use on a Google Map.

However, I'd like to have it store the region of the point as well so I can use it for filtering the entry (North America, South America, Asia, Europe, Africa, Australia).

Is there a way to use the Google Maps API to determine the region of a geolocation?

+1  A: 

The Google Geocoder returns the country. Example:

     <Country>
      <CountryNameCode>US</CountryNameCode>
      <AdministrativeArea>
        <AdministrativeAreaName>CA</AdministrativeAreaName>
       <SubAdministrativeArea>
         <SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName>
        ...

mapping countries to regions should be easy or easier to do.

Here is a list that would need some manual work: Countries by region

You may find a pre-filled table with ISO code to region mappings with some searching.

Pekka
So you don't think google provides the region data for a point? I was hoping to make a simple javascript call to the api to determine the region.
proee
Good idea but I'm not sure mapping countries to regions is trivial. I know I've sat through boring discussions about it.
MarkJ
The United Nations Statistical Division seems to have some sort of official classification: see http://unstats.un.org/unsd/methods/m49/m49regin.htm
Pekka
I replaced the link in my answer with the UN one.
Pekka
My programming skills are limited so I was hoping to have an easy solution. My backup is to require the user to select their region, but that seems unnecessary if they've already entered in their country.
proee
Mapping latitude / longitude to region is not going to be trivial, I'm afraid. Maybe some other Geocoding service can provide region data but if Google doesn't....
Pekka
@proee: Re your 1st comment: One would think that Google could easily provide that information, but it doesn't seem that they do. There is a similar discussion on the Google Maps API forums http://groups.google.co.in/group/google-maps-api/browse_thread/thread/b6c21bf4e7a47394 with the same outcome.
Pekka
Thanks for all your help everyone... This is my first post to stackoverflow and I'm amazed by the quick response.
proee