1

I am using geotools to transform a set of point in chile EPSG:5359 to world EPSG:4326

I am using below code

transform("6884327.77", "447076.76");

static Coordinate transform(String Easting, String Northing) throws Exception {   
    GeometryFactory geometryFactory = new GeometryFactory();
    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:5359");
    //System.out.println(sourceCRS);
    CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
    WKTReader reader = new WKTReader(geometryFactory);
    Point point = (Point) reader.read("POINT (" + Easting + " " + Northing + ")");

    System.out.println(point.toString());

    MathTransform mTrans = CRS.findMathTransform(sourceCRS, targetCRS);
    Geometry transformed = JTS.transform(point, mTrans);
    Coordinate cordinatesingle = transformed.getCoordinate();
    Coordinate[] cordinate = transformed.getCoordinates();
    System.out.println(cordinatesingle.getX());
    System.out.println(cordinatesingle.getY());
    return cordinatesingle;
}

I debugged and found out it goes into DefaultCoordinateSequenceTransformer class and then here it returns NAN. Why does it return NAN? Do I need another transformer for this?

1
  • 1
    Are you sure that the axis order is correct when you build the point?
    – Ian Turton
    Commented Jan 31, 2023 at 17:56

1 Answer 1

1

Your source point cannot be in EPSG:5359

https://epsg.org/crs_5359/SIRGAS-Chile-2002.html?

That coordinate system is Ellipsoidal 3D CS. Axes: latitude, longitude, ellipsoidal height. Orientations: north, east, up. UoM: degree, degree, metre.

The units in your coordinates "6884327.77", "447076.76" are probably meters. Find out the proper EPSG code for your data.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.