Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How do I get the city and country names from the output of FindGeoLocation[] {lat, long} ?

share|improve this question
    
This answer How do I plot coordinates (latitude and longitude pairs) on a geographic map? contains a related and useful function (nearLC) to find two nearest big cities (of population over 100000) for every geo-location point. –  Artes Jun 17 '13 at 21:38

2 Answers 2

One way is to do this:

nc = Nearest[
  CityData[#, "Coordinates"] -> # & /@ 
     CityData[{All, "United Kingdom"}]];

Then use this as:

nc[FindGeoLocation[]]

{{"London", "GreaterLondon", "UnitedKingdom"}}

share|improve this answer
    
(I'm in the UK - your mileage might vary... :)) –  cormullion Jun 17 '13 at 21:17

The fastest is probably with the use of the GeoNames API*:

loc = FindGeoLocation[]
i = Import[
"http://api.geonames.org/findNearby?lat=" <> ToString[loc[[1]]] <> 
"&lng=" <> ToString[loc[[2]]] <> "&username=demo", "XML"];
name = Cases[i[[2, 3, 1, 3]], XMLElement["name", _, x_] -> x]

*Idea from this post.

EDIT: another option is the use of WolframAlpha plugin in mathematica:

WolframAlpha["near cities"]
(* or *)
= near cities

wolframalpha output

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.