Added by jgarnett, last edited by jgarnett on Dec 12, 2007  (view change)

Labels

 
(None)

The GeoTiff Plugin allows the GeoTools Coverage Module to make use of GeoTiff files as a GridCoverage. The GeoTiff module maintainer has not yet provided any examples for the user guide, for now please consult the following blog post and module test cases.

References:

Code Example

Thanks to diegofd for helping add exception handling to the following example:

File file = new File("test.tiff");

GeoTiffReader reader;
try {
    reader = new GeoTiffReader(file, new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE));
} catch (DataSourceException ex) {
    ex.printStackTrace();
    return;
}

GridCoverage2D coverage;
try {
    coverage = (GridCoverage2D) reader.read(null);
} catch (IOException ex) {
    ex.printStackTrace();
    return;
}

// Using a GridCoverage2D
CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem2D();
Envelope env = coverage.getEnvelope();
RenderedImage image = coverage.getRenderedImage();