[GIS] What simple and light Java library to use for WGS84 to UTM conversion

coordinate systemcoordinatesjava

Geotools and Geotoolkit are huge and complicated.

CTS (1.3.3 from Maven) failed on me by not even being able to run its own test example (slightly modified https://github.com/orbisgis/cts/blob/master/src/test/java/org/cts/op/EPSGTransform.java gave me "This registry EPSG is not supported" while I did not even touch those strings).

So, are there any alternatives that are easy to use, not require additional libraries if possible (even loggers are annoying enough) and are free software?

All I want to do is turn some WGS84 coordinates to UTM32N (EPSG:25832) in Java.

Best Answer

From the GeoTools Referencing FAQ -

Can I just use Referencing without the rest of GeoTools? Yes, you will need to use the metadata module, and one of the epsg modules. Along with their dependencies such as units.

Then all you need to do is:

CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:25832");
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false);
Geometry targetGeometry = JTS.transform( sourceGeometry, transform);