0

I've got a problem transforming coordinates. The result differs in PostGIS and GeoTools.

I want to transform from EPSG:4326 to EPSG:3398.

PostGIS:

indicia=> select ST_AsText(ST_Transform(ST_GeomFromText('POINT(13.387527 54.094434)', 4326),3398)) as converted;
                converted                 
------------------------------------------
 POINT(4590768.20978302 5996697.68142438)
(1 row)

CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3398");
WKTReader wktReader = new WKTReader(new GeometryFactory(new PrecisionModel()));
WKTWriter wktWriter = new WKTWriter();
MathTransform mathTransform = CRS.findMathTransform(sourceCRS, targetCRS, true);
Geometry geom = wktReader.read("POINT(54.094434 13.387527)");
Geometry transformed = JTS.transform(geom, mathTransform);
System.out.println(wktWriter.write(transformed));

Returns: POINT (5996634.451525969 4590769.450296965)

This means the GeoTools result is about 60m south of the PostGIS result.

rgdal for R is giving the same result as PostGIS.

Am I doing something wrong in using geotools/jts?

7
  • what happens if you don't set lenient true in findTransform?
    – Ian Turton
    Apr 9, 2019 at 12:14
  • and which epgs database are you using?
    – Ian Turton
    Apr 9, 2019 at 12:15
  • lenient false results into an exception: org.opengis.referencing.operation.OperationNotFoundException: Bursa wolf parameters required.
    – dve
    Apr 9, 2019 at 12:56
  • The epsg database is gt-epsg-hsql 19.1 but also upgrading to 20.3 did not change the result
    – dve
    Apr 9, 2019 at 12:59
  • Probably means PostGIS is using the Bursa Wolf params and GeoTools doesn't know about them
    – Ian Turton
    Apr 9, 2019 at 13:14

0