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?