use of org.geotools.coverage.grid.io.AbstractGridCoverage2DReader in project polymap4-core by Polymap4.
the class GridServiceInfo method main.
// test ***********************************************
public static void main(String[] args) throws Exception {
// File f = new File( "/home/falko/Data/tiff/bluemarble.tif" );
File f = new File("/home/falko/Data/ncrast/elevation_4326.tif");
AbstractGridCoverage2DReader reader = GridCoverageReaderFactory.open(f);
System.out.println("reader: " + reader);
System.out.println("reader: " + reader.getInfo().getSource());
System.out.println("reader: " + reader.getInfo().getTitle());
System.out.println("reader: " + Arrays.asList(reader.getGridCoverageNames()));
System.out.println("reader: " + reader.getFormat().getName());
System.out.println("reader: " + reader.getCoordinateReferenceSystem());
System.out.println("reader: " + reader.getOriginalEnvelope());
System.out.println("reader: " + reader.getOriginalGridRange());
for (String name : reader.getGridCoverageNames()) {
ResourceInfo info = reader.getInfo(name);
System.out.println("coverage: " + info.getTitle());
System.out.println("coverage: " + info.getName());
System.out.println("coverage: " + info.getDescription());
System.out.println("coverage: " + info.getBounds());
}
reader.dispose();
}
use of org.geotools.coverage.grid.io.AbstractGridCoverage2DReader in project OpenTripPlanner by opentripplanner.
the class RasterPopulation method createIndividuals.
@Override
public void createIndividuals() {
LOG.info("Loading population from raster file {}", sourceFilename);
try {
File rasterFile = new File(sourceFilename);
// determine file format and CRS, then load raster
AbstractGridFormat format = GridFormatFinder.findFormat(rasterFile);
AbstractGridCoverage2DReader reader = format.getReader(rasterFile);
GridCoverage2D coverage = reader.read(null);
this.coverageCRS = coverage.getCoordinateReferenceSystem();
GridGeometry2D gridGeometry = coverage.getGridGeometry();
GridEnvelope2D gridEnvelope = gridGeometry.getGridRange2D();
gridGeometry.getGridToCRS();
// because we may want to produce an empty raster rather than loading one, alongside the coverage we
// store the row/col dimensions and the referenced envelope in the original coordinate reference system.
this.cols = gridEnvelope.width;
this.rows = gridEnvelope.height;
this.createIndividuals0();
} catch (Exception ex) {
throw new IllegalStateException("Error loading population from raster file: ", ex);
}
LOG.info("Done loading raster from file.");
}
Aggregations