Deconstructing Mercator

By Bill Thorp

These days, everybody uses mercator tilesetsCharlie and Morten both put forth excellent explanation of Mercator for us.  These two are both smart, smart guys.  I will attempt to give an unsmart explanation.

If you were to take a globe and count its degrees, you’d see the earth is 360 degrees around, and 180 degrees from pole to pole.  Easy!!  A circle’s circumference is 360 degrees, and also its radius * 2 * pi.  By that logic, 180 degrees = pi * r, and the earth is pi*r tall, and 2*pi*r wide.

Knowing the earth’s radius, then, we can calculate the circumference of the earth (2*pi*r).  The trick is, not everybody is willing to say that the earth is a sphere.  People who know fancy words are more inclined to describe our earth as an oblate spheroid — a somewhat flattened sphere. 

Morten’s WKTs inform us that WGS84 uses a spheroid of SPHEROID["...",6378137, 298.257223563] while Google uses a spheroid of SPHEROID["...", 6378137, 0].  It’s that third parameter thats interesting:  its the flattening factor.  It means WGS84 knows the earth is an oblate spheroid, while Google treats the earth as a perfect sphere.  6378137 meters is the semi-major axes of WGS84’s oblate world.  In Google’s world view, this number is simply the radius of the earth.

Sweet.  We know the radius of the Google’s earth.  We know the half-circumference of the earth, too, pi*r:  20037508.342789 meters.  Check the validMercator range for the Google projection and you’ll see a pattern:  [-20037508.3427892, -20037508.3427892] to [20037508.3427892, 20037508.3427892].  Morten is simply telling us that Google uses the circumference of the earth in meters!!

 But WAIIIIT.   The earth is pi*r tall, and 2*pi*r wide.  Half of those numbers should be half that!!  And they would be, in an unprojected/plate carre world; but Google uses a Mercator projection.  Referring to Wikipedia and our valid range, we can see that Mercator is happy to leave longitude alone.  But also from Wikipedia, “A Mercator map can never fully show the polar areas, since linear scale becomes infinitely high at the poles.”

 WHAT?  Yes, Mercator project has an infinite Y range.  We can’t have infinite bounds!! So how does Google make it look like a square?  Simple:  they chop off the poles. 

For simplicity’s sake, put your mental trig calculator into degree mode, or pretend the world has a radius of 1.  Take Wikipedia’s Mercator projection  { Y = log( tan( lat ) + sec( lat ) ) },  and solve with Y = 180.  You’ll arrive at a value of 85.051 degrees … which should again be familiar from Morten’s blog.  85.051 degrees is a magic latitude that gives Google their square earth.

So there you go:  A rough explanation of Mercator, and an only slightly better explanation of some of the WKT magic number behind hit.  Stay tuned for part two.

2 Responses to “Deconstructing Mercator”

  1. Deconstructing Mercator, Part 2 « MapWrecker 2.0 Says:

    [...] MapWrecker 2.0 AJAX, Maps, .NET, and Destruction « Deconstructing mercator [...]

  2. Telling StreetView where to go. - Avencia Labs Says:

    [...] future challenge I face is part of the classic battle of the 900913 projection vs. PA State Plane South. I predict heavy use of a sound-proofed room, the Proj4js forums and lots [...]

Leave a Reply