Deconstructing Mercator, Part 2
Summarizing last time: Google’s WKT includes SPHEROID[”…”, 6378137, 0], meaning the earth is a sphere with a radius of 6378137 meters. 6378137 * pi = 20037508, the half-circumference of the earth in meters, and the Mercator max range. Solve the Mercator equations so that max X = max Y, and you’ll find that happens at +/- 85.051 degrees latitude.
Notice this 85.051 degrees is a “magic number” in Mercator; it dictates a perfect Mercator square for the moon as well as it does the Earth. Our WKT says Google’s Mercator maps are based on meters. Yet Wikipedia’s math imagines a world with a radius of 1. Worse, Charlie rightly points out that Google’s APIs also imagines multiple Mercator worlds with various pixel dimensions!
In short, there is only one square Mercator projection of a sphere. Datum is the question. Your local WMS/IMS may need to know the earth is 6378137 meters in radius for conversion from other projections. One the other hand, it’d be happy with 6378.137 km, 31795.5 furlongs, or 6.7418e-10 lightyears, as long as you can explain the relationship. {You can tweak your WKT SPHEROID all day, as long as you equally modify your DATUM’s UNIT values.}
More to the point, no matter what your datum, there is only one defacto tile standard: 256×256 tiles, a 256×256 base map, n zoom levels, and a 2×2 zoom between levels. With tiles, the earth is 128*2^n/pi pixels in radius, end of story. Any Mercator datum can be turned into another simply by multiplying by the ratio of their diameters. Making a 6378137 m radius earth fit into 256×256 pixels is one such transformation of datum.
The fun thing, then, is coming up with a better datum. Google’s solution of pixel datums is certainly elegant. In many circumstances, however, we are trying to fit tiles to geographic coordinates. Here, a 360×360 unit Mercator Earth is a nice, clean option.
Remember that the Mercator projection does not touch longitude except for datum conversion. Hence, with a 360×360 Mercator Earth, longitude is equal to X already. Mercator Y can be derived from latitude using the simple { Y = log( tan( lat ) + sec( lat ) ) } equation.
And that’s Mercator. Fin.
March 1, 2008 at 7:12 am
[...] 2.0 AJAX, Maps, .NET, and Destruction « Back in Black Deconstructing Mercator, Part 2 [...]