[geotk] coordinate transformation from 3857 to 4326
juergen sorg
j.sorg at fz-juelich.de
Fri Mar 19 04:48:15 PDT 2021
hi,
i have a question about transforming coordinates from epsg:3857 (google)
to epsg:4326 (lon lat). (i am not sure if this is the right place to ask
for - but i am using geotk with jts).
in [0] you can find a code snippet to transform a point and in [1] the
results.
my questions are:
1. why are the coordinates not swapped, because after the transformation
x-coord and the y-coord are at the wrong place.
2. do i have to swap it by my own and if yes then how can i do it with
e.g. polygons
3. why the crs is still 3857 after transformation (it should 4326) and
if i have to change it by my own how this can be accomplished?
thanks in advance
regards,
juergen
[0]
WKTReader WKT_READER = new WKTReader(
new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 3857));
String pt_google="POINT(704377.78268943 6533181.663612)";
Geometry pt_google_geom=WKT_READER.read(pt_google);
Geometry pt_wgs84_geom=JTS.transform(pt_google_geom,
CRS.findOperation(CRS.forCode("EPSG:3857"),
CRS.forCode("EPSG:4326"), null).getMathTransform());
Geometry pt_google_geom_transformed=JTS.transform(pt_wgs84_geom,
CRS.findOperation(CRS.forCode("EPSG:4326"),
CRS.forCode("EPSG:3857"), null).getMathTransform());
System.out.println(pt_google_geom);
System.out.println(pt_google_geom.getSRID());
System.out.println(pt_wgs84_geom);
System.out.println(pt_wgs84_geom.getSRID());
System.out.println(pt_google_geom_transformed);
System.out.println(pt_google_geom_transformed.getSRID());
[1]
POINT (704377.78268943 6533181.663612)
3857
POINT (50.499200582184564 6.327533279841338)
3857
POINT (704377.7826894299 6533181.663611999)
3857
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5335 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20210319/25c6bba7/attachment.bin>
More information about the Geotoolkit
mailing list