-
Notifications
You must be signed in to change notification settings - Fork 7
CoordinatesTransformation
Christian Gendreau edited this page Nov 25, 2013
·
26 revisions
This feature should be used with cautious
The accuracy of processed coordinates depends on the precision of the provided coordinates and the transformation needed. Accuracy can differ from one CRS to another. You should always test the result to ensure the accuracy is suitable for you.
The transformations are accomplished using GeoTools 10 [JTS API] (http://docs.geotools.org/latest/userguide/library/api/jts.html).
In order to use this processor, you need to include some GeoTools 10 dependencies to your project:
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>10.0</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>10.0</version>
</dependency>
CoordinatesToWGS84Processor ctwProcessor = new CoordinatesToWGS84Processor();
CoordinateReferenceSystem crs;
try {
crs = CRS.decode("EPSG:26912"); //NAD83 / UTM zone 12N
ProcessingResult pr = new ProcessingResult();
Double[] coordinates = ctwProcessor.process(548566d,4935158d, crs, pr);
System.out.println("lat:"+coordinates[LatLongProcessorHelper.LATITUDE_IDX] + " , long:" + coordinates[LatLongProcessorHelper.LONGITUDE_IDX]);
} catch (NoSuchAuthorityCodeException e) {
e.printStackTrace();
} catch (FactoryException e) {
e.printStackTrace();
}
//prints: lat:44.56812235120222 , long:-110.38837721812456You can also provide the exact WTK using GeoTools CRS.parseWKT(String wtk) function.
- You should be aware of possible issues with WKT representation: http://home.gdal.org/projects/opengis/wktproblems.html
- WKT related specifications: http://www.opengeospatial.org/standards/ct