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.

  • GeoTools is just 2 jars to do this :-) – Ian Turton Jun 19 '15 at 12:59
  • Last time I tried Geotools it was an afternoon of annoyed frustration. Which jars do you mean? – bugmenot123 Jun 19 '15 at 13:02

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);
  • Thanks, I added gt-metadata-13.1.jar and gt-epsg-hsql-13.1.jar to my project. Now I am stuck again. How do I create the CRSs and what is the JTS class here? I do use JTS standalone together with JUMP so far. edit: Ok, I figured out the CRS creation but I see you added it too. Thanks! Still mystified about the "JTS". – bugmenot123 Jun 19 '15 at 13:23
  • For WGS84 to UTM32N, your source CRS will be 4326 and your target CRS will be 32632 -- EPSG as the authority. – Mintx Jun 19 '15 at 13:28
  • looks like the FAQ is economical - you need gt-api too to get JTS (though technically you don't need it for reprojection). – Ian Turton Jun 19 '15 at 13:33
  • if you are really strapped for space just use: final double[] array = new double[transform.getTargetDimensions()]; copy(source, array); transform.transform(array, 0, array, 0, 1); switch (transform.getTargetDimensions()) { case 3: dest.z = array[2]; // Fall through case 2: dest.y = array[1]; // Fall through case 1: dest.x = array[0]; // Fall through case 0: break; } – Ian Turton Jun 19 '15 at 13:35
  • I had gotten it work with gt-jts-wrapper-13.1.jar too, gt-api-13.1.jar works too. No idea what the difference is... Launch takes a good couple of seconds but I guess that is Geotools for me. Thank you! – bugmenot123 Jun 19 '15 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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