Hi all,

I have a problem with coordinate transformation results (EPSG:4326 to
EPSG:31467) - geotools (18.2) results in northing deviates from most results
of other transformation libraries I tried by around 1-2 meters. I.e.
https://epsg.io/transform#s_srs=4326&t_srs=31467&x=9.0000000&y=50.0000000  .
I know the results are quite accurate and for maps sufficient enough, but
the results of other libraries (gdal, a homegrown library and others) are
more closely spaced, geotools deviates "systematically".
For a quick check you can try it with lon 9° lat 50°.
Can anybody explain this difference and give some clues what can be done?
No, gt-epsg-wkt is not in the classpath and I am aware of numerical accuracy
and different more or less precise calculation methods. 

Regards,
Jessica

Here is what I tried:

import com.vividsolutions.jts.geom.Coordinate;

import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;

public class Test4 {

    final MathTransform transform;

    public Test4() throws FactoryException {

        CoordinateReferenceSystem geographic = CRS.decode("EPSG:4326");
        CoordinateReferenceSystem projected = CRS.decode("EPSG:31467");
        transform = CRS.findMathTransform(geographic, projected, false);
        System.out.println(
                "geographic: " + CRS.getAxisOrder(geographic) + " projected:
" + CRS.getAxisOrder(projected) + " " +
transform.getClass().getCanonicalName());
    }

    public Coordinate transform(Coordinate coordinate) throws
TransformException {
        return JTS.transform(coordinate, null, transform);
    }

    public static void main(String[] args) throws FactoryException,
TransformException {
        double[] xComponent = {50.0, 49.31697225, 48.01593456, 53.56584087,
49.46711705, 49.46359125, 49.46790631, 49.47109095, 49.45559285,
49.47497621,
                52.17121958, 49.27232523, 49.40419504, 49.39821486,
49.16149286, 49.15742017, 49.11177234, 49.11076685, 49.47711921,
49.47908686, 49.2772704};
        double[] yComponent = {9.0, 8.51894939, 9.47737743, 9.82497393,
7.63700611, 7.64303598, 7.65064303, 7.65386702, 7.64339468, 7.6400998,
10.63546034,
                7.59703019, 7.67746683, 7.68134721, 7.61524541, 7.62056884,
7.72511502, 7.72363407, 8.14619403, 8.16198793, 7.90487983};

        Test4 transformer = new Test4();

        for (int i = 0; i < xComponent.length; i++) {

            Coordinate point = transformer.transform(new
Coordinate(xComponent[i], yComponent[i]));

            System.out.println(
                    xComponent[i] + " \t" + yComponent[i] + " \t" + point.y
+ " \t" + point.x + " \t" + Math.round(point.y) + " \t" +
Math.round(point.x));
        }
    }
}

Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to