/** * Load a raster from a file. * * @param filename * the filename of the raster * @return the loaded raster as an AbstractRaster * @throws IOException */ public static AbstractRaster loadRasterFromFile( File filename ) throws IOException { RasterIOOptions options = RasterIOOptions.forFile( filename ); return loadRasterFromFile( filename, options, null ); }
/** * loads the raster * * @param tileBaseDir * @return the loaded simpleraster * @throws IOException */ public AbstractRaster loadRaster( String tileBaseDir ) throws IOException { File file = new File( getFullFileName( tileBaseDir ) ); RasterReader reader = new IIORasterReader(); RasterIOOptions options = RasterIOOptions.forFile( file, getEnvelope() ); return reader.load( file, options ); }
private static void transformRaster( String[] args, String srcCRS, String dstCRS, InterpolationType type, OriginLocation location ) { try { MemoryTileContainer tileContainer = new MemoryTileContainer(); for ( int i = 0; i < args.length - 1; i++ ) { if ( args[i] != null ) { File f = new File( args[i] ); RasterIOOptions options = RasterIOOptions.forFile( f ); options.add( RasterIOOptions.GEO_ORIGIN_LOCATION, location.name() ); tileContainer.addTile( RasterFactory.loadRasterFromFile( f, options ) ); } } AbstractRaster srcRaster = new TiledRaster( tileContainer, null ); RasterTransformer transf = new RasterTransformer( dstCRS ); srcRaster.setCoordinateSystem( CRSManager.getCRSRef( srcCRS ) ); AbstractRaster result = transf.transform( srcRaster, type ); RasterFactory.saveRasterToFile( result, new File( args[args.length - 1] ) ); } catch ( Exception ex ) { System.err.println( "Couldn't transform raster file: " ); ex.printStackTrace(); System.exit( 2 ); } }
RasterIOOptions nOpts = options; if ( nOpts == null ) { nOpts = RasterIOOptions.forFile( filename );
try { LOG.info( "Creating raster from file: {}", filename ); RasterIOOptions newOpts = RasterIOOptions.forFile( filename ); newOpts.copyOf( options ); AbstractRaster raster = RasterFactory.loadRasterFromFile( filename, newOpts );
try { LOG.info( "Creating raster from file: {}", filename ); RasterIOOptions newOpts = RasterIOOptions.forFile( filename ); newOpts.copyOf( options ); AbstractRaster raster = RasterFactory.loadRasterFromFile( filename, newOpts, null );