/** * Returns columns of the raster. * * @return width in pixel */ public int getColumns() { return getRasterReference().getSize( getEnvelope() )[0]; }
/** * Returns rows of the raster. * * @return height in pixel */ public int getRows() { return getRasterReference().getSize( getEnvelope() )[1]; }
private void instantiate( int targetColumns, int targetRows, Envelope rasterEnvelope, RasterGeoReference geoRef, File gridFile, RasterDataInfo dataInfo ) { synchronized ( LOCK ) { if ( rasterEnvelope == null ) { throw new NullPointerException( "The grid writer needs an envelope to work with." ); } if ( geoRef == null ) { throw new NullPointerException( "The grid writer needs a raster georeference to work with." ); } this.envelope = geoRef.relocateEnvelope( OriginLocation.OUTER, rasterEnvelope ); this.columns = targetColumns; this.rows = targetRows; this.geoRef = geoRef.createRelocatedReference( OriginLocation.OUTER ); int[] rasterCoordinate = this.geoRef.getSize( this.envelope ); this.gridFile = gridFile; // if ( this.gridFile != null && !this.gridFile.exists() ) { // this.gridFile.createNewFile(); // } this.dataInfo = dataInfo; this.tilesInFile = columns * rows; this.tileRasterWidth = Rasters.calcTileSize( rasterCoordinate[0], columns ); this.tileRasterHeight = Rasters.calcTileSize( rasterCoordinate[1], rows ); // this tile data does not need to be cached. updateForRasterSize(); } }
/** * Creates a new empty SimpleRaster with same DataType and InterleaveType. Size is determined by the given envelope. * * @param rEnv * The raster envelope of the new SimpleRaster. * @param env * The boundary of the new SimpleRaster. * @return A new empty SimpleRaster. */ public SimpleRaster createCompatibleSimpleRaster( RasterGeoReference rEnv, Envelope env ) { int[] size = rEnv.getSize( env ); RasterRect rasterRect = new RasterRect( 0, 0, size[0], size[1] ); RasterData data = this.getRasterData(); BandType[] bands = data.getDataInfo().bandInfo; RasterData newRaster = data.createCompatibleWritableRasterData( rasterRect, bands ); return new SimpleRaster( newRaster, env, rEnv, metadata ); }
int[] size = geoReference.getSize( rasterEnvelope ); width = size[0]; height = size[1];