Group Abstract Group Abstract

Message Boards Message Boards

Incorrect locator GeoPosition error in Manipulate[GeoGraphics[]]

Posted 1 month ago

I used Locator in Manipulate[] to update mouse click point in GeoGraphics[]. The returned GeoPositionp[ from Locator has error in Latitude largely. See the following code. In this Poland map, Warsaw has {52.23,21.01} in latitude,longitude. Initialization of Locator to Warsaw did not work and there is 9.13 degree error in the latitude. It is huge error in location.

Manipulate[
 Column[
  {
   "LocPos",
   LocPos,
   GeoGraphics[GeoRange -> {{48, 56}, {12, 27}}, 
    GeoBackground -> "StreetMap", ImageSize -> Large]
   }
  ]
 ,
 {{LocPos, GeoPosition[{52.23, 21.01}]}, Locator}  
 ]
Attachment

Attachment

POSTED BY: Yeonjoon Park
2 Replies
Posted 1 month ago

Thank you. It solved my problem.

POSTED BY: Yeonjoon Park

Hi, the problem here is the difference between geographic coordinates {lat, lon}, as taken by GeoPosition, and then the map projected coordinates {x, y}, as used by Graphics and the locator. We need to do this:

First construct the map of the region:

map = GeoGraphics[GeoRange -> {{48, 56}, {12, 27}}, GeoBackground -> "StreetMap", ImageSize -> Large];

See which projection it is using, in this case the "Mercator" projection:

In[2]:= proj = GeoProjection /. Options[map, GeoProjection]
Out[2]= "Mercator"

These are the geographic coordinates of Warsaw:

In[3]:= GeoPosition[Entity["City", {"Warsaw", "Mazowieckie", "Poland"}]]
Out[3]= GeoPosition[{52.232, 21.0067}]

and these are its projected coordinates in the "Mercator" projection:

In[4]:= warsaw = GeoGridPosition[%, proj]["GridXY"]
Out[4]= {21.0067, 61.4643}

Now we can construct the needed Manipulate:

Manipulate[Column[{"LocPos", GeoPosition[GeoGridPosition[LocPos, proj]], map}], {{LocPos, warsaw}, Locator}]

enter image description here

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard