WebMercator to Geographic and back gives a different point

363
5
12-03-2020 02:32 PM
AmarG1
by
New Contributor II

Hi,

Using WebMercatorUtils to convert a point from webmercator to geographic and then back to webmercator doesn't give the original value back. Any ideas why?

point1: {x: -27763769.230105422, y: -6212655.210572942}

webMercatorUtils.webMercatorToGeographic() on point1 returns point2

point2: {x: 110.5938175582902, y: -48.63203914410154}

webMercatorUtils.geographicToWebMercator() on point2 returns point3

point3: {x: 12311247.455472855, y: -6212655.210572806}

I was hoping point1 and point3 to be same but that doesn't seem to be the case. 

Thanks!

0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

same datum for the geographic?  There are many GCS's


... sort of retired...
AmarG1
by
New Contributor II

Hi Dan,

I tried this instead:

point1 = {"spatialReference":{"wkid":3857},"x":-27763769.230105422,"y":-6212655.210572942}

let point2 = webMercatorUtils.project(point1, { wkid: 4326 });

point2 : {"spatialReference":{"wkid":4326},"x":110.5938175582902,"y":-48.63203914410154}

let point3 = webMercatorUtils.project(point2, { wkid: 3857 });

point3: {"spatialReference":{"latestWkid":3857,"wkid":102100},"x":12311247.455472855,"y":-6212655.210572806}

Does that address datum?

Thanks!

0 Kudos
DanPatterson
MVP Esteemed Contributor

That isn't due to a datum difference assuming your long/lat values are correct 

You can confirm using an online calculator


... sort of retired...
0 Kudos
AmarG1
by
New Contributor II

I'm getting the same response from https://tool-online.com/en/coordinate-converter.php#

-Thanks

0 Kudos
DanPatterson
MVP Esteemed Contributor

here are the images for various combinations from there.

coord_convert3.pngcoord_convert2.pngcoord_convert1.pngcoord_convert0.png

so assuming this is correct... and you have checked your inputs


... sort of retired...
0 Kudos