Coffeehouse Thread

11 posts

Get city & country for latitude and longitude

Back to Forum: Coffeehouse
  • BeSharp

    Can anybody recommend either a Web Service or an offline database solution which would allow me to get the city and country for any given latitude and longitude?


    (Free solutions/services preferred but possible commercial solutions are welcome, too!)

    -Ralf

  • ZippyV
  • BeSharp

    ZippyV said:
    Thanks ZippyV,

    I did the search on C9 myself, however, that discussion thread does unfortunately NOT answer the question I've posted here.

    I'll repeat for the sake of being clear:

    I know many services (Yahoo Maps API, etc.) that allow you to get Latitude and Longitude information when you send an address as the input. I do need it the other way around.

    All I want to send as INPUT parameter ist Latitude and Longitude and as a return result I'd need city and country.

    Any hints?

  • ZippyV

    BeSharp said:
    ZippyV said:
    *snip*
    Thanks ZippyV,

    I did the search on C9 myself, however, that discussion thread does unfortunately NOT answer the question I've posted here.

    I'll repeat for the sake of being clear:

    I know many services (Yahoo Maps API, etc.) that allow you to get Latitude and Longitude information when you send an address as the input. I do need it the other way around.

    All I want to send as INPUT parameter ist Latitude and Longitude and as a return result I'd need city and country.

    Any hints?
    With that topic I did find a list but it didn't end up on Channel 9.

    But I found it back:
    http://earth-info.nga.mil/gns/html/namefiles.htm

  • BeSharp

    ZippyV said:
    BeSharp said:
    *snip*
    With that topic I did find a list but it didn't end up on Channel 9.

    But I found it back:
    http://earth-info.nga.mil/gns/html/namefiles.htm
    Wow! With the data files made available there I might be able to set up my own web service to convert stuff! Great hint! Thanks!

  • ZippyV

    BeSharp said:
    ZippyV said:
    *snip*
    Wow! With the data files made available there I might be able to set up my own web service to convert stuff! Great hint! Thanks!
    Don't be too euphoric, the lists are not clean and contain other things like mountains, rivers, lakes. It's almost impossible to get a clean list of only cities and villages based on filtering the other columns.

  • BeSharp

    ZippyV said:
    BeSharp said:
    *snip*
    Don't be too euphoric, the lists are not clean and contain other things like mountains, rivers, lakes. It's almost impossible to get a clean list of only cities and villages based on filtering the other columns.
    Well, I only need to get a city from lat and long. I really wonder that none of the map providers (Google, Yahoo, MS) seem to have a web service for that. All of them offer you to input an address and get lat/long back but not vice versa...

  • figuerres

    BeSharp said:
    ZippyV said:
    *snip*
    Well, I only need to get a city from lat and long. I really wonder that none of the map providers (Google, Yahoo, MS) seem to have a web service for that. All of them offer you to input an address and get lat/long back but not vice versa...

    one interesting thing:

    http://maps.google.com/maps?ll=27.950739,-82.459259  will give you a map of tampa, fl

    when dealing with locations your database would need to have it updated often as names and countries do chnage.

    another issue is how you determine the "city" from LL
    LL math to find the distance between two locations can get a bit complex,  as I recall it's called the Great Circle formla as it takes the cuve of the earth into account.

    given a point and a distance you may get multiple location names, if several have non-zero distance and are very close which one do you pick?

  • andokai

    That activity is called reverse geocoding . Do a google search and you can find loads of free choices. It is possible to do it with the map point web service as demonstrated here

  • Mark Brown

    Yes, Virtual Earth provides a reverse geocoding service in the platform API.

    You can see this in our Interactive SDK, http://dev.live.com/virtualearth/sdk expand "Find Information (Basic)", then click on "Reverse Find"

    MSDN Library for this, http://msdn.microsoft.com/en-us/library/cc469978.aspx

    You'll have the parse the output if you just want city/state but that's pretty trivial.

    Enjoy.

  • Niner

    If you just want the list, Check the World Wide Telescope. It has the long list of cities with lat & long which again might be based on Virtual Earth only.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.