21

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

Kuba
  • 136,707
  • 13
  • 279
  • 740
vonkohorn
  • 471
  • 2
  • 7

2 Answers2

16

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.

Kuba
  • 136,707
  • 13
  • 279
  • 740
jose
  • 6,328
  • 1
  • 14
  • 24
  • I agree, maybe should've stressed what is supposed to be reported to WRI - documentation with gaps. – Kuba Jun 02 '16 at 18:45
  • 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? – Kuba Jun 02 '16 at 18:56
  • 1
    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. – jose Jun 03 '16 at 14:57
  • 1
    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. – jose Jun 03 '16 at 15:14
11

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

Kuba
  • 136,707
  • 13
  • 279
  • 740