-1

Is there a way to transform a EPSG:3857 projection to EPSG:4326 in java? I'm using the esri java sdk. I went through the esri skd docs, but couldn't find a way to transform EPSG:3857 to EPSG:4326. Is there a way of doing it?

I have a webMercator like this: Point property = new Point(1.7040237624799997e7,-3099509.4953500014, SpatialReferences.getWebMercator());

And have a WSG84 like this Point point1 = new Point(153.089361, -26.802295, SpatialReferences.getWgs84());

I need to merge them and as those points have different Spatial References I can't display a map property.

Rafael Paz
  • 497
  • 7
  • 22

1 Answers1

1

I'm assuming you are using the ArcObjects SDK for Java? Then the following code should work because your Point class is implementing the IGeometry interface according to esri java doc

https://desktop.arcgis.com/en/arcobjects/latest/java/api/arcobjects/com/esri/arcgis/geometry/IGeometry.html

Point property = new Point(1.7040237624799997e7,-3099509.4953500014, 
                           spatialReferences.getWebMercator());
Point reprojected = property.project(SpatialReferences.getWgs84());

Because your Point constructor looks like you're using one of the newer Esri SDKs like ArcGIS Pro SDK or Runtime SDK I'm adding a solution for them too:

Point originalPoint = new Point(1.7040237624799997e7,-3099509.4953500014, 
                          spatialReferences.getWebMercator());
Point projectedPoint = (Point) GeometryEngine.project(originalPoint, 
                           SpatialReference.create(4326));

according to https://developers.arcgis.com/java/latest/sample-code/project.htm

GeofoxCoding
  • 285
  • 1
  • 9