How do I convert a particular point on a Mercator map (points in a Mercator map svg) to WGS84 coordinates? Is it simply a direct translation of the x,y values, using a multiplier which matches the map width & height to -180..180 and -90..90?
1 Answer
WGS84 is an ellipsoidal coordinate system. The math for these conversions is considerably more involved than if we used a spherical model of the Earth; that's one of the reasons why people like Google opted for Web Mercator, which plots WGS84 coordinates using a spherical model, the error caused by this being negligible for most everyday uses.
If using a spherical model of the Earth and introducing some error is okay:
Provided the map is in the usual aspect (i.e., Equator runs left-right through the vertical center of the map), the longitude is as simple as you suggest only if Greenwich, England (the Prime Meridian) is in the center of the map. The latitude is not that simple in any case.
You need to use the inverse formulas for the Mercator projection. See these on page 44 of John Snyder's book (http://pubs.usgs.gov/pp/1395/report.pdf). Your globe radius R can be determined from the length of the Equator in your image, which is the circumference of the globe, and your x,y points on the image need to be determined relative to 0 lat and 0 long, where the Prime Meridian meets the Equator.
If you need very high accuracy, take a look at the inverse formulas for the ellipsoid, again by John Snyder, page 44.
-
Given the size of a typical computer screen and a user clicking on the svg image, I doubt you need the accuracy of the ellipsoid, by the way. Nov 22, 2015 at 20:20
-
Thank you for the explanation. Would this formula already likely be implemented in proj4 using "+proj=merc"? Nov 22, 2015 at 20:29
-
@JTileson I think so, but the input data needs to be defined in a projection Proj4 understands before it will convert correctly. Nov 22, 2015 at 20:51