Added by jgarnett, last edited by jgarnett on Jul 05, 2007  (view change)

Labels

 
(None)

The JTS Utility class is used to smooth out some of the common JTS Geometry activities

Using a Math Transform to Reproject a Geometry

You can use a MathTransform directly - it has methods for feeding DirectPosition instances in one at a time and seeing the answers pop out. The problem is our JTS Geometry instances are built out of Coordinate instances rather than using DirectPosition.

The JTS utility class defines a helper method for this common activity

JTS Utility Class
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;

CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:23032");

MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
Geometry targetGeometry = JTS.transform( sourceGeometry, transform);

Reference: