1

My main goal is to achieve the same conversion as to the following command using geotools.

cs2cs -f "%.7f" +init=epsg:23700 +nadgrids=etrs2eov_notowgs.gsb +geoidgrids=geoid_eht2014.gtx +to +init=epsg:4258

Basically I would like to convert points from EOV to ETRS89 with high precision, so I would like to use correction grids.

So far I created the following java program:

public static void main(String... args) throws Exception {
    initialize();

    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:23700");
    CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4258");
    MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
    checkTransform(transform);

    DirectPosition2D srcDirectPosition2D = new DirectPosition2D(sourceCRS, 650000, 180000);
    DirectPosition2D destDirectPosition2D = new DirectPosition2D(targetCRS);
    transform.transform(srcDirectPosition2D, destDirectPosition2D);
    System.out.println(destDirectPosition2D);
}

private static void checkTransform(MathTransform transform) throws Exception {
    if (!transform.toString().contains("NTv2")) {
        throw new Exception("Latitude and longitude difference file not loaded.");
    }
}

private static void initialize() {
    System.setProperty("org.geotools.referencing.forceXY", "true");
    ReferencingFactoryFinder.addAuthorityFactory(new WKTOperationFactory("transform_overrides.properties"));
}

My transform_overrides.properties looks the following:

4258,23700=PARAM_MT["NTv2", PARAMETER["Latitude and longitude difference file", "etrs2eov_notowgs.gsb"]]

These are the two files that are needed for the conversion:

http://www.agt.bme.hu/on_line/etrs2eov/etrs2eov_notowgs.gsb http://www.agt.bme.hu/on_line/etrs2eov/geoid_eht2014.gtx

My problem is that the source point (650000 180000) is not converted to the desired CRS (should be: 19.04745712900 46.96421283181).

Moh
  • 1,588
  • 1
  • 9
  • 17
George
  • 11
  • 2
  • I think you need to tell GeoTools about both files - see if http://docs.geoserver.org/stable/en/user/configuration/crshandling/coordtransforms.html#add-grid-shift-transform-files helps – Ian Turton Apr 05 '18 at 13:24
  • Thank you, I already did that. While debugging I noticed that NTv2Transform thinks that the specified coordinate is not within the Grid. I'm not sure why... – George Apr 06 '18 at 06:11
  • @George Did you end up getting it to work? What folder did you copy the .gtx file and the "transform_overrides.properties" file to? WKTOperationFactory seems to be part of geocalc, not GeoTools, do you have to use that to use a .gtx file? – Neph Feb 05 '20 at 11:01

0 Answers0