The map looks right, but the Latitude in the Frame looks wrong.

Am I making a mistake or is this a bug?

enter image description here


This is not a bug. When dealing with a map there are two different coordinate systems you need to handle, related by the cartographic projection you are using.

First you have the {lat, lon} coordinates on the surface of the Earth's ellipsoidal model. These are the numbers in GeoPosition[{lat, lon}].

Then you have the coordinate {x, y} on the flat map of the Earth. These are the numbers in GeoGridPosition[{x, y}, projection]. The projection specifies the function that converts from {lat, lon} to {x, y} or viceversa. When you do GeoGridPosition[GeoPosition[{lat, lon}], projection] you get GeoGridPosition[{x, y}, projection]. If you wrap the latter with GeoPosition, you get GeoPosition[{lat, lon}] back. The "Equirectangular" projection is basically defined as x = lon, y = lat. But other projections (say "Mercator") have nontrivial formulas.

The map needs to use the map coordinates, that is {x, y}, and that is way your "Mercator" map does not agree with the expected {lat, lon} coordinates.

  • $\begingroup$ I agree, maybe should've stressed what is supposed to be reported to WRI - documentation with gaps. $\endgroup$ – Kuba Jun 2 '16 at 18:45
  • $\begingroup$ I'm confused. Isn't Mercator latitude codomain supposed to be [-Pi, Pi]? They are rescaling it to Degree which makes no sense (for me) and is confusing (for me). What do you think? $\endgroup$ – Kuba Jun 2 '16 at 18:56
  • 1
    $\begingroup$ The latitude phi range [-Pi, Pi] is mapped into Mercator y coordinate range [-Infinity, Infinity]. The transformation is y = Log[Tan[phi/2 + Pi/4]]. It is traditional in map webservers to show only the {x, y} square [-Pi, Pi] x [-Pi, Pi] of Mercator space, which corresponds to about [-85, 85] degrees in latitude. This means that Mercator maps do not show the geo disks of about 5 degrees radius around the poles, but that is not a big problem because around the North pole there is mostly water and around the South pole it is all ice. That is why GeoGraphics uses "Equirectangular" for world maps. $\endgroup$ – jose Jun 3 '16 at 14:57
  • 1
    $\begingroup$ The question of whether to use radians or degrees is a different discussion. This is controlled by the "ReferenceModel" parameter of the projections. Try GeoProjectionData["Mercator"] and you will see the rescaling 180/Pi to convert to degrees, but something like "Albers" has model 1. The Geo functionality in the WL is degree-oriented, as determined by the main object, GeoPosition. The decision was to rescale back to degrees the cylindrical projections only, because for them the x projected coordinate is proper longitude. This was done to preserve most of the conventions of CountryData. $\endgroup$ – jose Jun 3 '16 at 15:14

To long for a comment:

It seems that Geo-FrameTicks are not handled well unless we use "Equirectangular" GeoProjection. Even if it is a cylindrical projection, as a "Mercator" used here, the result's ticks seem to be rescaled badly.

I can't find anything about that in documentation so I'm encouraging you to report that to WRI Support.

Meanwhile use "Equirectangular" projection if you need ticks:

GeoGraphics[ GeoPosition @ {42.31, -71.19}, 
  GeoGridLines  -> Automatic, 
  Frame         -> True, 
  GeoProjection -> "Equirectangular",
  GeoRange      -> Quantity[10, "Miles"]

enter image description here

If you need different projections you can create custom FrameTicks (notice that GeogridLines are correct anyway) like I did in: GeoProjection for astronomical data - wrong ticks

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.