AnsweredAssumed Answered

Converting from WebMercator to Wgs84

Question asked by headtr1p on Feb 13, 2020
Latest reply on Feb 13, 2020 by headtr1p

I have a set of points (drawn polygon) that have the SpatialReferences.WebMercator property. I need to convert these points to SpatialReferences.Wgs84 before saving to a database. Ideally I would just keep the WebMercator setting, but the existing database is using the Wgs84 format.


I am using the GeometryEngine class, but I noticed that once I reload the polygon, it is off by some way. It is in a different location. How can I make sure this conversion is accurate?


public double[] ConvertMercatorToWgs(double lat, double lon)

      MapPoint point = new MapPoint(lon, lat, SpatialReferences.WebMercator);


      //These lines did not influence the results

      //GeographicTransformationStep geoStep = new GeographicTransformationStep(108211);
      //GeographicTransformation geoTransform = new GeographicTransformation(geoStep);


      MapPoint convertedPoint = (MapPoint)GeometryEngine.Project(point, SpatialReferences.Wgs84,);


      return new double[] { convertedPoint.X, convertedPoint.Y };