# Trying to convert coordinates from WGS84 Web Mercator Auxiliary Sphere to WGS84

I've been struggling with this for way too long now. I've got some data that was georeferenced in the WGS84 Web Mercator Auxiliary Sphere that should have been done just in WGS84.

The Auxiliary Sphere (ESPG: 3857) is the projection commonly used by Google, Bing, and recently ArcGIS Online. The projected coordinates I have are in meters, as per Aux Sphere specs, but I've got to convert them to degrees and bring them into WGS84.

I know the Aux Sphere is just a projected version of WGS84, but I can't seem to wrap my mind around converting coordinates from a projected coordinate system to a geographic coordinate system.

I have some code that will convert from WGS84 Web Mercator (WKID: 102113) to WGS84, but because that system uses a spherical globe, rather than the ellipsoid used by WGS84 and the Aux Sphere, my results are a bit off. I've tried modifying it, but I can't seem to get it just right.

Here's my code if that is helpful:

``````public static void ToGeographic(ref double[] mercator)
{
if (Math.Abs(mercator) < 180 && Math.Abs(mercator) < 90)
return;

if ((Math.Abs(mercator) > 20037508.3427892) || (Math.Abs(mercator) > 20037508.3427892))
return;

double x = mercator;
double y = mercator;
double num3 = x / 6378137.0;
double num4 = num3 * 57.295779513082323;
double num5 = Math.Floor((double)((num4 + 180.0) / 360.0));
double num6 = num4 - (num5 * 360.0);
double num7 = 1.5707963267948966 - (2.0 * Math.Atan(Math.Exp((-1.0 * y) / 6378137.0)));
mercator = num6;
mercator = num7 * 57.295779513082323;

}
``````
• The "Aux Sphere" version just has a parameter that says use the semimajor axis as the radius and then the sphere-based equations. I don't see anything wrong, beyond the first check (those values are perfectly acceptable in Mercator although the area's offshore). What are you getting and what do you think you should be getting? Aug 20, 2013 at 18:27
• Here's a sample point. x = -10000000, y = +5000000. latitude = 40.91627447, longitude = -89.83152841 Aug 20, 2013 at 18:32
• Excellent. It's nice to get some validation on that. So my coordinates are getting transformed correctly, but I'm still having a problem with my data. I'm editing world files for some TIFF and JPEG images. I guess the problem I'm having is with the pixel size and rotation at this point, but that's getting off topic on this post. Thanks for your help! Aug 20, 2013 at 21:13
• It is simple but please one of you post the answer and check it. We want to promote GOOD question/answer practice Aug 21, 2013 at 4:36