Saturday 21 October 2017

coordinate system - Grid shift transformations based on GSD and GDX files (like cs2cs does)


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).




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...