I want to convert the (x,y) coordinates you get from using a locator on a map to Lat/Lon coordinates - exactly like the GetCoordinates tool does when you right click on a map.

Manipulate[GeoGraphics[GeoPosition[{51.5164090, -0.0943590}],
GeoRange -> Quantity[0.20, "Miles"]], {u, Locator}, {u}]

ie if I create a simple map and use use right click -> GetCoordinates it will give me 3 pairs of values

  1. Lat Lon
  2. Lat Lon in degrees
  3. (x,y) <-- this is the one Locator returns.

Simple demo map

GeoGraphics[GeoPosition[{51.5164090, -0.0943590}], 
GeoRange -> Quantity[10, "Miles"]]

Im presuming its related to GeoPositionENU somehow but the starting point seems to change for each instance of the map.


If you examine the AbsoluteOptions for the GeoGraphics you can see what is used by the Get Coordinates tool: CoordinatesToolOptions.

g = GeoGraphics[GeoPosition[{51.5164090, -0.0943590}], 
  GeoRange -> Quantity[0.20, "Miles"], ImageSize -> 600];

(* {DisplayFunction->
                                        ]&)} *)

Pull out the "DisplayFunction" and use that function:

tr = "DisplayFunction" /. (CoordinatesToolOptions /. AbsoluteOptions[g]); 

Here I define function that takes care of the Automatic case.

trans[u_] := tr[u]
trans[Automatic] = tr[Mean /@ (PlotRange /. AbsoluteOptions[g])];


Manipulate[Column[{Style[trans[u], {16, "Text"}], g}], {u, Locator}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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