Search in sources :

Example 1 with GeoTiffReader

use of org.geotools.gce.geotiff.GeoTiffReader in project OpenTripPlanner by opentripplanner.

the class GeotiffGridCoverageFactoryImpl method getGridCoverage.

@Override
public GridCoverage2D getGridCoverage() {
    try {
        // There is a serious standardization failure around the axis order of WGS84. See issue #1930.
        // GeoTools assumes strict EPSG axis order of (latitude, longitude) unless told otherwise.
        // Both NED and SRTM data use the longitude-first axis order, so OTP makes grid coverages
        // for unprojected DEMs assuming coordinates are in (longitude, latitude) order.
        Hints forceLongLat = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
        GeoTiffFormat format = new GeoTiffFormat();
        GeoTiffReader reader = format.getReader(path, forceLongLat);
        coverage = reader.read(null);
        LOG.info("Elevation model CRS is: {}", coverage.getCoordinateReferenceSystem2D());
    } catch (IOException e) {
        throw new RuntimeException("Error getting coverage automatically. ", e);
    }
    return coverage;
}
Also used : Hints(org.geotools.factory.Hints) GeoTiffFormat(org.geotools.gce.geotiff.GeoTiffFormat) GeoTiffReader(org.geotools.gce.geotiff.GeoTiffReader) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Hints (org.geotools.factory.Hints)1 GeoTiffFormat (org.geotools.gce.geotiff.GeoTiffFormat)1 GeoTiffReader (org.geotools.gce.geotiff.GeoTiffReader)1