Monday, September 15, 2014

Advisory notice on "Web Mercator"

4037 NGA raster nautical charts displayed upon Google Maps imagery
(Marine GeoGarage

NGA released a cease and desist regarding webmapping products for navigation and targeting due to inaccuracies with the default map.

I just learn that National Geospatial-Intelligence Agency (NGA) published some recent documents (February & May 2014) regarding the use of Web Mercator projection originally adopted by the leaders of the Internet (created for Google Maps, then adopted for Microsoft Virtual Earth, Yahoo Maps), and also embraced by other commercial API providers (OpenLayers, Leaflet, ArcGIS for JS...).
This term is used to refer to the fact that these providers use a specific Mercator projection which is neither strictly ellipsoidal, nor strictly spherical.
So this affects calculations done based on processing the map as a flat plane.

 "Maps from G. Mercator are worthless" (translation from French)

I don't say that NGA seems to discover webmapping, 9 years after the introduction of Google Maps in 2005 and the adoption of this specific projection for their maps and imagery, but this is an old debate since the arrival of the first geo web actors, what Dodge & Perkins examined in 2008 as an apparent decline in mapping quality ("McMaps", amateur(ish) maps made by non-experts or neogeographers).
On a technical point of view, Noel Zinn (in 2010) and more recently Daniel Streb (in 2012) have perfectly explained before NGA the technical issues relative to the choice of a pseudo Mercator projection.

In 2009, International Association of Oil & Gas Producers (OGP which created the EPSG codes) described quite well the Coordinate Conversions and Transformations including Formulas for this projection (see the evolution in the time of the EPSG codes for Google Mercator,  not a recognised geodetic system in the last Web Mercator -Auxiliary Sphere- EPSG:3857 version.
"We have reviewed the coordinate reference system used by Microsoft, Google, etc. and believe that it is technically flawed. We will not devalue the EPSG dataset by including such inappropriate geodesy and cartography." said EPSG.

1.3.3.2 Popular Visualization Pseudo Mercator
(EPSG dataset coordinate operation method code 1024)
This method is utilized by some popular web mapping and visualization applications.
It applies standard Mercator (Spherical) formulas (section 1.3.3.1 above) to ellipsoidal coordinates and the sphere radius is taken to be the semi-major axis of the ellipsoid.
This approach only approximates to the more rigorous application of ellipsoidal formulas to ellipsoidal coordinates (as given in EPSG dataset coordinate operation method codes 9804 and 9805 in section 1.3.3 above).
Unlike either the spherical or ellipsoidal Mercator projection methods, this method is not conformal: scale factor varies as a function of azimuth, which creates angular distortion.
Despite angular distortion there is no convergence in the meridian. 

 EPSG definition said in 2006 the projection "uses spherical development of ellipsoidal coordinates."

 extract from OGP publication

So Web Mercator is really a non conformal projection : scale factor in the N/S meridian direction not equal to scale factor in E/W parallel direction : not a constant, but a function of azimuth (direction).
By the way, Google Maps chose for its pseudo Web Mercator to use a radius of the Earth equal to the semimajor axis of the WGS84/GRS80 reference ellipsoid (Equatorial radius : 6,378,137.0 meters), which is much larger than the Mean radius whose value is about 6,371,007.0 meters used in Mercator Spherical).
But actually Web Mercator is "almost conformal" when looking at small areas...
An infinitesimal circle drawed on the ellipsoid surface, would become an ellipse on the map, but an ellipse with a very small flattening, and really similar to a circle.
For this reason deformation of shape is very small too when looking at small areas, and is not visually notable : a square building is projected as a (almost) square building.
For memory, conserving the shape of square buildings was one of the major reason for the choice of this specific pseudo Mercator by the original Google Maps team (Where2 Technologies startup co-founded by Jens and Lars Rasmussen brothers), and adopted by many web maps today.
Note : the first launch of Google Maps actually did not use pseudo Mercator but Plate Carree, and streets in high latitude places like Stockholm did not meet at right angles on the map the way they do in reality.
The majority of Google Maps users are looking down at the street level for businesses, directions, etc...
While this distorts a 'zoomed-out view' of the map, it allows close-ups (street level) to appear more like reality.

with GDAL/PROJ4 tools : delta = 36.3 km at Lat = 58°
echo -5.0 58.0 | cs2cs -f “%.10f” +init=epsg:4326 +to +init=epsg:3395 (Geo2Mercator)
=> -556,597.454, 7,931,049.576
echo -5.0 58.0 | cs2cs -f “%.10f” +init=epsg:4326 +to +init=epsg:3857 (Geo2WebMercator)
=> -556,597.454, 7,967,317.535
The units of web Mercator are not really Meters, they are "Web Mercator Meters"
and they are equal only on the Equator line.
When you go north or south from the Equator line, the ratio (difference in Northing between Mercator and Web Mercator) between the two units is getting bigger.

However, although Web Mercator shares some of the same properties of the standard Mercator projection (north is up everywhere, areas near the poles are greatly exaggerated), rhumb lines (or loxodromes, lines of constant true heading that navigators used to sail before GPS) are not straight lines.

courtesy of Noel Zinn document

So as non-conformal with not straight loxodromes, this projection should not be really called “Mercator” according the terms of IHO : Web Mercator can't be used for navigation.

Actually the aim of Google Maps was at first visualization of maps and aerial/satellite imagery on the web and not to be a tool for accurate surveying computations : Web Mercator wouldn’t be used for surveying, geodetic or scientific purposes.

To simplify the calculations, we use the spherical form of this projection, not the ellipsoidal form. Since the projection is used only for map display, and not for displaying numeric coordinates, we don’t need the extra precision of an ellipsoidal projection. The spherical projection causes approximately 0.33% scale distortion in the Y direction, which is not visually noticeable. 
(source : Bing Maps Tile System)

However, Web Mercator is a projection that maps from ellipsoidal WGS84 LatLon (LL) to XY in Web Mercator meters and back to ellipsoidal LL : so a completely reversible LLXY.
The first version of the public Marine GeoGarage website (unprojecting back plotted waypoints in Web Mercator meters to WGS84 LatLon coordinates) proposed some Route planning tool allowing the user to save the waypoints and routes created with the webmapping in gpx or Garmin formats to be use in GPS or chart plotters.

The loss of conformality implied when using directly the simpler and faster spherical formulas, didn't worry his creators because Google Maps was targeted for the majority of people, so non specialist.
The reason for the creation of this specific pseudo Mercator simplifying mathematical calculations was Javascript performance (scale factor not computed).
Reprojection of the coordinates to the Web Mercator projection (from EPSG:4326 to EPSG:3857):
x = a*λ (a = WGS4 semi-major axis -Equatoril radius- 6,378,137m)
y = a*arctanh(sinφ) − a*e*arctanh(e*sinφ) : eccentricity (e) of the Earth not taken into account (eq 0) in Web Mercator (for info e=0.081819190842621)
so (Lat
φ and Lon λ are in radians) about 5 times faster than the ellipsoidal Mercator

 zoom level 1 has 4 square tiles

By the way, in order to get an entire world map similar to a (very large) square (pyramidal tiles : 256 px x 256 px), Google Maps uses some bound in Latitude (85.0511° = arctan(sinh(π))


Web applications are a very important platform because of their ability to reach a large number of people easily.
Web Mercator as the pioneer projection chosen for 2D webmapping became the standard for sharing data on the web because of the richness of the offer in matter of maps and imagery provided by the giants of the Internet.
That's also the main reason why we decided to match the nautical charts with satellite and aerial imagery, in order to align properly with the services such as these popular contents.
-> see GeoGarage blog :
http://blog.geogarage.com/2012/11/south-pacific-sandy-island-proven-not.html
http://blog.geogarage.com/2011/01/bahamas-wlp-update-in-marine-geogarage.html

By the way, we must recall that the GeoGarage nautical charts web and mobile viewers are not to be used as a primary tool for navigation.
The goal is not to replace the existing Electronic Chart System for navigation, but to provide a maritime route planning tool accessible for a large audience.


As the basic quandary is the accuracy issue in 2D Planisphere web viewers, why not approaching reality using a 3D Globe ?

Google Earth viewer using re-projecting on the fly individual tiles 
in Mercator to Plate Carree before rendering them.
However kml format proved to not be very adapted for adding a custom streamable large tileset.

In the next future, with the ongoing advent of HTML5 and WebGL, developing virtual globe applications running in the web browser without any plug-in will allow to stay focus on the visualization.

 see video : UKHO Multitouch demo


While the sphere is a close approximation of the true figure of the Earth and satisfactory for many purposes, geodesists have developed a number of models to represent a closer approximation to the shape of the Earth, using a cartesian XYZ coordinate frame of reference (Earth-Centered, Earth-Fixed -ECEF- used in GPS) and datum transformation to the more commonly used geodetic-mapping coordinates of Latitude, Longitude, and Altitude (LLA).
But portraying the reality of our planet as a nearly spherical surface in a three-dimensional world is also a challenge, especially if we plan to integrate altitudes and bathymetry.

 Google Maps (Earth) new version on WebGL-enabled browser

The best of the ellipsoïdal and Geoid models can represent the shape of the earth over the smoothed, averaged sea-surface to within about one-hundred meters.
Through a long history, the "figure of the Earth" was refined from flat-Earth models to spherical models of sufficient accuracy to allow global exploration, navigation and mapping.


But like with the use of 2D world viewers on the web, if you work in some field that required accurate maps, you would not necessarily find globes in common use.

 Gerard Mercator's 1541 terrestrial globe on display in the Harvard Map Collection exhibit hall.
Along with a 1551 celestial globe, this is one of only 22 surviving matched pairs in the world, and the only matched pair in America.

The most accurate globe would be a globe the size of earth itself.
Jorge Luis Borges's "On Exactitude in Science" describes the tragic uselessness of the perfectly accurate, one-to-one map (Map as a Territory):
In time, those Unconscionable Maps no longer satisfied, and the Cartographers Guild drew a Map of the Empire whose size was that of the Empire, coinciding point for point with it. The following Generations, who were not so fond of the Study of Cartography saw the vast Map to be Useless and permitted it to decay and fray under the Sun and winters.
In the Deserts of the West, still today, there are Tattered Ruins of the Map, inhabited by Animals and Beggars; and in all the Land there is no other Relic of the Disciplines of Geography.


Links :

4 comments: