This question is based on another question: I'm converting multiple images (.jpg or .png) from one EPSG defined CRS system to another, e.g. from EPSG:31255 to EPSG:25833 (on a server within a Java app).
Currently I'm using this code (GeoTools 22.2, Java 8):
//codeIn file (already includes TOWGS84): http://epsg.io/31255.wkt
String codeOut = "epsg:25833";
public void convert(String pathIn, String pathOut, String codeOut) {
File fileIn = new File(pathIn);
if(fileIn.exists() && fileIn.isFile()) {
try {
File fileOut = new File(pathOut);
CoordinateReferenceSystem crsOut = CRS.decode(codeOut);
AbstractGridFormat format = GridFormatFinder.findFormat(fileIn);
Hints hints = null;
AbstractGridCoverage2DReader reader = format.getReader(fileIn, hints);
GridCoverage2D coverage = reader.read(null);
reader.dispose();
GridCoverage2D coverageTransf = (GridCoverage2D) Operations.DEFAULT.resample(coverage, crsOut);
GeoTiffFormat outFormat = new GeoTiffFormat();
GridCoverageWriter writer = outFormat.getWriter(fileOut, hints);
writer.write(coverageTransf, null);
writer.dispose();
} catch(Exception e) {
e.printStackTrace();
}
}
}
Now I want to add high precision to it. In Proj4 I'd use this command:
+ellps=bessel +nadgrids=GIS_GRID.gsb +proj=tmerc +lat_0=0 +lon_0=13d20 +k=1 +x_0=0 +y_0=-5000000 +units=m +no_defs +geoidgrids=foo.gtx +to +datum=WGS84 +proj=utm +zone=33 +no_defs
In this similar question there's a link to a website that tells you to copy the two files (.gsb and .gtx) to the user_projections folder, which of course doesn't exist in my app.
My guess is that I'll have to give GridCoverage2D coverage = reader.read(null) some type of GeneralParameterValue[]. Is this the right way to do it and if so, how exactly do I give it the path of the two files and/or the command?
OSTN02_NTv2.gsband I've never tried to change it's name – Ian Turton Jan 31 '20 at 13:50AT_GIS_GRID.gsbavailable from http://www.bev.gv.at/portal/page?_pageid=713,2157075&_dad=portal&_schema=PORTAL – Ian Turton Jan 31 '20 at 13:53INVERSE_MT[PARAM_MT["NTv2", PARAMETER["Latitude and longitude difference file", "AT_GIS_GRID.gsb"]]], thanks! I was just told that the .gtx file and the rest of the command aren't actually needed as it's unambiguous with the used epsg code and gsb file anyway. So thanks again for your help! – Neph Feb 05 '20 at 12:03envelopehere but it's from 2009. Could you please point me in the right direction where I can find the function to use? – Neph Feb 06 '20 at 10:48