# Understanding the Mercator Projection

To illustrate my problem, let's say I have lattitude and longitude coordinates, such as 38.871105, -77.056042. I want to be able to calculate the new lattitude and longitude if, say, I moved 300m eastwords, or 400m northwards, in a way that google maps will like. Now, from what I can understand, this would mean converting it from lat/long to mercator pixel coordinates, getting new mercator pixel coordinates then converting back to lat/long...

Here's what Wikipedia has to say on Google's Mercator projection:

Why do the above equations not actually take into account the longitude? And what is a? If I could understand these equations then theoretically the rest should be easy... Thanks! -B

• Your problem is not projection dependent. The map projection relates spherical coordinate system to some other (this may be pixel coordinates, physical space etc.). Since Google Maps API will handle lat/lon input, you just need to calculate your travel distance. Distance (in meters) northward is linearly proportional to distance in degrees latitude. Distance (in meters) eastward will depend on a cosine of latitude besides being linearly proportional to distance in longitude. Also, look into great circle distances and Haversine formula and others for higher accuracy calculations. – milancurcic Nov 5 '14 at 14:07
• I think it would be good if you post what you found as the answer. – milancurcic Nov 6 '14 at 16:06
• a = semimajor axis of the ellipsoid or sphere used for the model of the Earth. – mkennedy Dec 18 '14 at 23:22

The Mercator Projection has been used and it is used since the XVI century due to it maintain the course, rhumb or route. So it is useful for navigation.

As the Earth is approached by a ellipsoid, then you get the formulas that you saw on Mercator Projection. This transformation it is complicated for a ellipsoid, as the Earth curvature it is not a constant, so in the example you gave (moving 300m eastwords, or 400m northwards), you need to transform the first point from geographical coordinates to rectangular coordinates, then shift the point 300 meters east, check the correction on distance due to the different curvature on each point, apply the correction, then shift the point 400 meters northwards, check the correction, apply the correction and bring the coordinates back to geographical coordinate.

That is to much computing time and there are a lost of precision loss on the different shiftings and transformation geographical <-> rectangular coordinates. Web Mercator is just a Mercator that considers the Earth approach by an sphere, not a ellipsoid. That is much easier, needs less computation as, the curvature in a sphere is constant it is not required to consider.

Regarding the constants... a is the semi-major axis of an ellipsoid, amap is the semi-major axis on the map (as the Mercator Projection is distorting the distances, you should make a distance correction, that it is become bigger as far as you are from the Equator) e is the eccentricity of the ellipsoid.

Regarding the latitude issue... Thing a little bit on this question: In the Mercator Projection it is consider, as Earth approach a sphere and a revolution ellipsoid. Both surfaces are revolution surfaces so, there is no variation along the longitude way. That is why the longitude is not required for Y calculation.

Anyhow, is something is not clear, just let me know. Hope it helps!

Google's "Web Mercator" projection is a very different beast from the Mercator projection. The former provides a coordinate system for the area you are viewing, oriented in the way you rotated the view.

The formulas you put in your original question are probably more computationally efficient when used for this purpose, but they do not foster understanding.

In fact, those formulas are obfuscatory, since they include an eccentricity term $$e$$ (this is not the base of the natural logarithms), but Google uses a spherical model where $$e=0$$.

The letter $$a$$ (the one without the subscript) is typically used for an ellipsoid's semimajor axis (for Earth this is about 6378 km depending on the geodetic model used). When assuming a spherical Earth, use $$R$$ instead, to refer to Earth's "radius".

$$a_{map}$$, on the other hand, is the map scale, the desired ratio between distances between points on the ground and their corresponding points on the map.

Notice that the equations you provide give derivatives, that is, the rate of change of one parameter based on another. They give $$dx/dE$$ and $$dy/dN$$ instead of $$x$$ and $$y$$. E and N are the coordinates derived by rotating and aligning the Earth to your view. Because Google assumes a sphere, you can get them by running the latitude and longitude through an azimuthal equidistant projection with the given center and rotation.

The Mercator projection is a cylindrical one, that is, the coordinate system is developed by wrapping a cylinder around the Earth, projecting its features onto the cylinder, and then unrolling the cylinder to lie flat.

This causes the lines of latitude and longitude to form a rectangular grid. In such a projection, the ratio between the final x coordinate and the longitude is a constant. This constant is $$a*a_{map}$$ using the notation from the original question. Thus, changes in scale do not depend on the longitude, so longitude does not appear in the formulas.

It's also a conformal projection, meaning that the distance distortion values for the two dimensions are the same.

More intuitive formulas calculate x and Y directly. For the spherical case, in the equatorial aspect:

$$x=R*a_{map}*(\lambda-\lambda_0)$$

$$y=R*a_{map}*ln \left[ tan \left(\frac{\pi}{4} +\frac{\phi}{2}\right)\right]$$

The ellipsoidal formula is more complicated:

$$y=a*a_{map}* ln \left[ tan \left(\frac{\pi}{4} +\frac{\phi}{2}\right) * \left(\frac{1-e* sin\phi}{1+e*sin \phi}\right)^\frac{e}{2} \right]$$

(It's one of the simplest ellipsoidal projection formulas, however!)

These formulas appear in the Wikipedia article on the Mercator projection and are the ones you should pay attention to.

The theory or purpose behind the Web Mercator projection is to project the globe into a rectangle made up of equally sized tiles at any zoom level. It's accuracy is highly suspect for calculating area's and distance; it is used because it makes it fast and easy to cache tiles to serve imagery and other basemaps. Rather than use the formula on Wikipedia i would look up EPSG:3857 (Mercator). As for using Google maps, it lets you toggle the reference system in the viewer from decimal to lat/long.

• "it is horribly inaccurate for modeling or processing data". This statement is false. Mercator projection is commonly used in ocean and atmosphere modeling, curvilinear grids facilitating high accuracy on arbitrary projections. – milancurcic Nov 5 '14 at 15:07
• I'll caveat by saying its horribly inaccurate at modeling or geoprocessing for use in landscape or watershed and/or terrestrial land planning as is distorts the relationship between distance between features.. I'm talking specifically about the web Mercator projection used by Google and other basemap services. That said I stand by the statement – user33290 Nov 5 '14 at 15:20
• Heh, it seems I wasn't sure what I was looking for now. Done a bit more research now, and in conjunction with the answer above I realize that use of the Mercator projection is completely unnecessary (even if it is fascinating stuff). Thankoo! <3 – bmus Nov 6 '14 at 14:48
• In EPSG:3857 aka "Web Mercator", the world is a square, not a rectangle, because it's cut off at approximately +/-85.05 degrees. – mkennedy Dec 18 '14 at 23:17
• @milancurcic I think the point that user33290 is making is that Google Maps does not use Mercator projection. It uses a simplified version called "Web Mercator", which saves on processing time. – Semidiurnal Simon Dec 19 '14 at 10:45