public class Band extends MajorObject
The Band class is a binding for the C++ GDALRasterBand class.
Band objects are returned by methods from other classes, such as Dataset.GetRasterBand() Users of the Java bindings must be aware that the Java primitive types byte, short, int are signed types, whereas a few GDAL data types (GDT_Byte, GDT_UInt16 and GDT_UInt32) are unsigned. To read/write those data types, you may have to choose a "larger" type for example (short/GDT_Int16 for GDT_Byte, int/GDT_Int32 for GDT_UInt16, double/GDT_Float64 for GDT_UInt32), or use some tricks to hold unsigned values into signed data type. For example :
byte[] byteArray = new byte[xsize * ysize]; byte[] byteArray2 = new byte[xsize * ysize]; band.ReadRaster(0, 0, xsize, ysize, gdalconst.GDT_Byte, byteArray); for(int j=0; j < ysize; j++) { for(int i=0; i < xsize; i++) { byte bVal = byteArray[j*xsize+i]; // ranging from -128 to 127 int nVal = ((int)bVal) & 0xff; // remapped to range from 0 to 255 int nVal2; if (nVal > threshold) nVal2 = 255; else nVal2 = 0; byte bVal2 = (nVal2 > 127) ? nVal2 - 256 : nVal2; // remapped to range from -128 to 127 byteArray2[j*xsize+i] = bVal2; } } band2.WriteRaster(0, 0, xsize, ysize, gdalconst.GDT_Byte, byteArray2);
Modifier and Type | Method and Description |
---|---|
int |
Checksum()
Compute checksum for while image.
|
int |
Checksum(int xoff,
int yoff,
int xsize,
int ysize)
Compute checksum for image region.
|
void |
ComputeBandStats(double[] meanAndStdDevArray)
Compute mean and standard deviation values.
|
void |
ComputeBandStats(double[] meanAndStdDevArray,
int samplestep)
Compute mean and standard deviation values.
|
void |
ComputeRasterMinMax(double[] minMaxArray)
Compute the min/max values for a band.
|
void |
ComputeRasterMinMax(double[] minMaxArray,
int approx_ok)
Compute the min/max values for a band.
|
int |
ComputeStatistics(boolean approx_ok)
Compute image statistics.
|
int |
ComputeStatistics(boolean approx_ok,
double[] min,
double[] max)
Compute image statistics.
|
int |
ComputeStatistics(boolean approx_ok,
double[] min,
double[] max,
double[] mean,
double[] stddev)
Compute image statistics.
|
int |
ComputeStatistics(boolean approx_ok,
double[] min,
double[] max,
double[] mean,
double[] stddev,
ProgressCallback callback)
Compute image statistics.
|
int |
CreateMaskBand(int nFlags)
Adds a mask band to the current band.
|
void |
delete()
Deprecated.
Do not do anything...
|
int |
Fill(double real_fill)
Fill this band with a constant value.
|
int |
Fill(double real_fill,
double imag_fill)
Fill this band with a constant value.
|
void |
FlushCache()
Flush raster data cache.
|
int |
GetBand()
Fetch the band number.
|
void |
GetBlockSize(int[] pnBlockXSize,
int[] pnBlockYSize)
Fetch the "natural" block size of this band.
|
int |
GetBlockXSize()
Fetch the "natural" block width of this band
|
int |
GetBlockYSize()
Fetch the "natural" block height of this band
|
Vector |
GetCategoryNames()
Fetch the list of category names for this raster.
|
int |
GetColorInterpretation()
How should this band be interpreted as color?
|
ColorTable |
GetColorTable()
Fetch the color table associated with band.
|
int |
getDataType()
Return the data type of the band.
|
int |
GetDefaultHistogram(double[] min_ret,
double[] max_ret,
int[][] histogram_ret)
Fetch default raster histogram.
|
int |
GetDefaultHistogram(double[] min_ret,
double[] max_ret,
int[][] histogram_ret,
boolean force)
Fetch default raster histogram.
|
int |
GetDefaultHistogram(double[] min_ret,
double[] max_ret,
int[][] histogram_ret,
boolean force,
ProgressCallback callback)
Fetch default raster histogram.
|
RasterAttributeTable |
GetDefaultRAT()
Fetch default Raster Attribute Table.
|
int |
GetHistogram(double min,
double max,
int[] histogram)
Compute raster histogram.
|
int |
GetHistogram(double min,
double max,
int[] histogram,
boolean include_out_of_range,
boolean approx_ok)
Compute raster histogram.
|
int |
GetHistogram(double min,
double max,
int[] histogram,
boolean include_out_of_range,
boolean approx_ok,
ProgressCallback callback)
Compute raster histogram.
|
int |
GetHistogram(int[] histogram)
Compute raster histogram.
|
Band |
GetMaskBand()
Return the mask band associated with the band.
|
int |
GetMaskFlags()
Return the status flags of the mask band associated with the band.
|
void |
GetMaximum(Double[] val)
Fetch the maximum value for this band.
|
void |
GetMinimum(Double[] val)
Fetch the minimum value for this band.
|
void |
GetNoDataValue(Double[] val)
Fetch the no data value for this band.
|
void |
GetOffset(Double[] val)
Fetch the raster value offset.
|
Band |
GetOverview(int i)
Fetch overview raster band object.
|
int |
GetOverviewCount()
Return the number of overview layers available.
|
Vector |
GetRasterCategoryNames()
Fetch the list of category names for this raster.
|
int |
GetRasterColorInterpretation()
How should this band be interpreted as color?
|
ColorTable |
GetRasterColorTable()
Fetch the color table associated with band.
|
int |
GetRasterDataType()
Return the data type of the band.
|
void |
GetScale(Double[] val)
Fetch the raster value scale.
|
int |
GetStatistics(boolean approx_ok,
boolean force,
double[] min,
double[] max,
double[] mean,
double[] stddev)
Fetch image statistics.
|
int |
GetStatistics(int approx_ok,
int force,
double[] min,
double[] max,
double[] mean,
double[] stddev)
Fetch image statistics.
|
String |
GetUnitType()
Return raster unit type.
|
int |
getXSize()
Fetch XSize of raster.
|
int |
GetXSize()
Fetch XSize of raster.
|
int |
getYSize()
Fetch YSize of raster.
|
int |
GetYSize()
Fetch YSize of raster.
|
boolean |
HasArbitraryOverviews()
Check for arbitrary overviews.
|
int |
ReadBlock_Direct(int nXBlockOff,
int nYBlockOff,
ByteBuffer nioBuffer)
Read a block of image data efficiently.
|
ByteBuffer |
ReadRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize)
Read a region of image data for this band.
|
int |
ReadRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
ByteBuffer nioBuffer)
Read a region of image data for this band.
|
ByteBuffer |
ReadRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type)
Read a region of image data for this band.
|
int |
ReadRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
ByteBuffer nioBuffer)
Read a region of image data for this band.
|
ByteBuffer |
ReadRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type)
Read a region of image data for this band.
|
int |
ReadRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
ByteBuffer nioBuffer)
Read a region of image data for this band.
|
int |
ReadRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
ByteBuffer nioBuffer,
int nPixelSpace,
int nLineSpace)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
byte[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
double[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
float[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
byte[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
double[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
float[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
int[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
byte[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
byte[] array,
int nPixelSpace,
int nLineSpace)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
double[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
double[] array,
int nPixelSpace,
int nLineSpace)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
float[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
float[] array,
int nPixelSpace,
int nLineSpace)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
int[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
int[] array,
int nPixelSpace,
int nLineSpace)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
short[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
short[] array,
int nPixelSpace,
int nLineSpace)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
short[] array)
Read a region of image data for this band.
|
int |
ReadRaster(int xoff,
int yoff,
int xsize,
int ysize,
short[] array)
Read a region of image data for this band.
|
int |
SetCategoryNames(Vector names)
Set the category names for this band.
|
int |
SetColorInterpretation(int eColorInterp)
Set color interpretation of a band.
|
int |
SetColorTable(ColorTable colorTable)
Set the raster color table.
|
int |
SetDefaultHistogram(double min,
double max,
int[] histogram)
Set default histogram
|
int |
SetDefaultRAT(RasterAttributeTable table)
Set default Raster Attribute Table.
|
int |
SetNoDataValue(double nodataValue)
Set the no data value for this band.
|
int |
SetOffset(double newoffset)
Set scaling offset.
|
int |
SetRasterCategoryNames(Vector names)
Set the category names for this band.
|
int |
SetRasterColorInterpretation(int eColorInterp)
Set color interpretation of a band.
|
int |
SetRasterColorTable(ColorTable colorTable)
Set the raster color table.
|
int |
SetScale(double newscale)
Set scaling ratio.
|
int |
SetStatistics(double min,
double max,
double mean,
double stddev)
Set statistics on band.
|
int |
SetUnitType(String newunittype)
Set unit type.
|
int |
WriteBlock_Direct(int nXBlockOff,
int nYBlockOff,
ByteBuffer nioBuffer)
Write a block of image data efficiently.
|
int |
WriteRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
ByteBuffer nioBuffer)
Write a region of image data for this band.
|
int |
WriteRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
ByteBuffer nioBuffer)
Write a region of image data for this band.
|
int |
WriteRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
ByteBuffer nioBuffer)
Write a region of image data for this band.
|
int |
WriteRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
ByteBuffer nioBuffer)
Write a region of image data for this band.
|
int |
WriteRaster_Direct(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
ByteBuffer nioBuffer,
int nPixelSpace,
int nLineSpace)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
byte[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
double[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
float[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
byte[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
double[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
float[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
int[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
byte[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
byte[] array,
int nPixelSpace,
int nLineSpace)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
double[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
double[] array,
int nPixelSpace,
int nLineSpace)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
float[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
float[] array,
int nPixelSpace,
int nLineSpace)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
int[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
int[] array,
int nPixelSpace,
int nLineSpace)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
short[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_xsize,
int buf_ysize,
int buf_type,
short[] array,
int nPixelSpace,
int nLineSpace)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
int buf_type,
short[] array)
Write a region of image data for this band.
|
int |
WriteRaster(int xoff,
int yoff,
int xsize,
int ysize,
short[] array)
Write a region of image data for this band.
|
GetDescription, GetMetadata_Dict, GetMetadata_Dict, GetMetadata_List, GetMetadata_List, GetMetadataDomainList, GetMetadataItem, GetMetadataItem, SetDescription, SetMetadata, SetMetadata, SetMetadata, SetMetadata, SetMetadata, SetMetadata, SetMetadataItem, SetMetadataItem
public void delete()
delete
in class MajorObject
public int GetXSize()
public int GetYSize()
public int GetRasterDataType()
A value such as gdalconst.GDT_Byte, gdalconst.GDT_Int16, ...
public int GetBlockXSize()
GetBlockSize(int[] pnBlockXSize, int[] pnBlockYSize)
public int GetBlockYSize()
GetBlockSize(int[] pnBlockXSize, int[] pnBlockYSize)
public int Checksum()
Computes a 16bit (0-65535) checksum from data on the raster band. Floating point data is converted to 32bit integer so decimal portions of such raster data will not affect the checksum. Real and Imaginary components of complex bands influence the result.
public int GetStatistics(boolean approx_ok, boolean force, double[] min, double[] max, double[] mean, double[] stddev)
Returns the minimum, maximum, mean and standard deviation of all pixel values in this band. If approximate statistics are sufficient, the approx_ok flag can be set to true in which case overviews, or a subset of image tiles may be used in computing the statistics.
If force is false results will only be returned if it can be done quickly (ie. without scanning the data). If force is false and results cannot be returned efficiently, the method will return CE_Warning but no warning will have been issued. This is a non-standard use of the CE_Warning return value to indicate "nothing done".
Note that file formats using PAM (Persistent Auxilary Metadata) services will generally cache statistics in the .pam file allowing fast fetch after the first request.
approx_ok
- If true statistics may be computed based on overviews
or a subset of all tiles.force
- If true statistics will only be returned if it can
be done without rescanning the image.min
- Allocated array of one double into which to load image minimum (may be null).max
- Allocated array of one double into which to load image maximum (may be null).mean
- Allocated array of one double into which to load image mean (may be null).stddev
- Allocated array of one double into which to load image standard deviation
(may be null).public int ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, ByteBuffer nioBuffer)
Same as below with buf_type == gdalconst.GDT_Byte, nPixelSpace == 0 and nLineSpace == 0
public int ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, ByteBuffer nioBuffer)
Same as below with buf_xsize = xsize, buf_ysize = ysize, buf_type == gdalconst.GDT_Byte, nPixelSpace == 0 and nLineSpace == 0
public ByteBuffer ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type)
Same as below with nPixelSpace == 0 and nLineSpace == 0 but buffer is allocated by the method
ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer nioBuffer, int nPixelSpace, int nLineSpace)
public ByteBuffer ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_type)
Same as below with buf_xsize = xsize, buf_ysize = ysize, nPixelSpace == 0 and nLineSpace == 0 but buffer is allocated by the method
ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer nioBuffer, int nPixelSpace, int nLineSpace)
public ByteBuffer ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize)
Same as below but buffer is allocated by the method
ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, java.nio.ByteBuffer nioBuffer)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, byte[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, byte[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, buf_type = gdalconst.GDT_Byte, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, short[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, short[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, buf_type = gdalconst.GDT_Int16, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, int[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, buf_type = gdalconst.GDT_Int32, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, float[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, float[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, buf_type = gdalconst.GDT_Float32, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, double[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, double[] array)
Same as below with buf_xsize = xsize, buf_ysize = ysize, buf_type = gdalconst.GDT_Float64, nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, ByteBuffer nioBuffer)
Same as below with buf_type == gdalconst.GDT_Byte, nPixelSpace == 0 and nLineSpace == 0
public int WriteRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_type, ByteBuffer nioBuffer)
Same as below with buf_xsize == xsize, buf_ysize == ysize, nPixelSpace == 0 and nLineSpace == 0
public int WriteRaster_Direct(int xoff, int yoff, int xsize, int ysize, ByteBuffer nioBuffer)
Same as below with buf_xsize == xsize, buf_ysize == ysize, buf_type == gdalconst.GDT_Byte, nPixelSpace == 0 and nLineSpace == 0
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, byte[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, byte[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, buf_type == gdalconst.GDT_Byte, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, short[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, short[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, buf_type == gdalconst.GDT_Int16, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, int[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, buf_type == gdalconst.GDT_Int32, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, float[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, float[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, buf_type == gdalconst.GDT_Float32, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_type, double[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, double[] array)
Same as below with buf_xsize == xsize, buf_ysize == ysize, buf_type == gdalconst.GDT_Float64, nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
public int getXSize()
public int getYSize()
public int getDataType()
A value such as gdalconst.GDT_Byte, gdalconst.GDT_Int16, ...
public int GetBand()
This method returns the band that this Band object represents within its dataset. This method may return a value of 0 to indicate Band objects without an apparently relationship to a dataset, such as Band's serving as overviews.
public void GetBlockSize(int[] pnBlockXSize, int[] pnBlockYSize)
GDAL contains a concept of the natural block size of rasters so that applications can organized data access efficiently for some file formats. The natural block size is the block size that is most efficient for accessing the format. For many formats this is simple a whole scanline in which case pnBlockXSize[0] is set to GetXSize(), and pnBlockXSize[1] is set to 1.
However, for tiled images this will typically be the tile size.
Note that the X and Y block sizes don't have to divide the image size evenly, meaning that right and bottom edge blocks may be incomplete. See ReadBlock_Direct() for an example of code dealing with these issues.
pnBlockXSize
- allocated array of 1 integer to put the X block size into or null.pnBlockYSize
- allocated array of 1 integer to put the Y block size into or null.public int GetColorInterpretation()
gdalconst.GCI_Undefined is returned when the format doesn't know anything about the color interpretation.
public int GetRasterColorInterpretation()
gdalconst.GCI_Undefined is returned when the format doesn't know anything about the color interpretation.
public int SetColorInterpretation(int eColorInterp)
eColorInterp
- the new color interpretation to apply to this band.public int SetRasterColorInterpretation(int eColorInterp)
eColorInterp
- the new color interpretation to apply to this band.public void GetNoDataValue(Double[] val)
The no data value for a band is generally a special marker value used to mark pixels that are not valid data. Such pixels should generally not be displayed, nor contribute to analysis operations.
val
- empty allocated array of type Double[] of size 1. val[0] will contain a Double object
with the no data value if available, other val[0] will contain nullpublic int SetNoDataValue(double nodataValue)
To clear the nodata value, just set it with an "out of range" value. Complex band no data values must have an imagery component of zero.
nodataValue
- the value to set.public String GetUnitType()
Return a name for the units of this raster's values. For instance, it might be "m" for an elevation model in meters, or "ft" for feet. If no units are available, a value of "" will be returned.
public int SetUnitType(String newunittype)
Set the unit type for a raster band. Values should be one of "" (the default indicating it is unknown), "m" indicating meters, or "ft" indicating feet, though other nonstandard values are allowed.
newunittype
- the new unit type value.public Vector GetRasterCategoryNames()
Raster values without associated names will have an empty string in the returned list. The first entry in the list is for raster values of zero, and so on.
public int SetRasterCategoryNames(Vector names)
See the GetCategoryNames() method for more on the interpretation of category names.
names
- a vector of strings with category names. May
be ,ull to just clear the existing list.public void GetMinimum(Double[] val)
For file formats that don't know this intrinsically, no value will be returned
val
- empty allocated array of type Double[] of size 1. val[0] will contain a Double object
with the minimum value if available, other val[0] will contain nullpublic void GetMaximum(Double[] val)
For file formats that don't know this intrinsically, no value will be returned
val
- empty allocated array of type Double[] of size 1. val[0] will contain a Double object
with the maximum value if available, other val[0] will contain nullpublic void GetOffset(Double[] val)
This value (in combination with the GetScale() value) is used to transform raw pixel values into the units returned by GetUnits(). For example this might be used to store elevations in GUInt16 bands with a precision of 0.1, and starting from -100.
Units value = (raw value * scale) + offset
For file formats that don't know this intrinsically, no value will be returned
val
- empty allocated array of type Double[] of size 1. val[0] will contain a Double object
with the offset value if available, other val[0] will contain nullpublic void GetScale(Double[] val)
This value (in combination with the GetOffset() value) is used to transform raw pixel values into the units returned by GetUnits(). For example this might be used to store elevations in GUInt16 bands with a precision of 0.1, and starting from -100.
Units value = (raw value * scale) + offset
For file formats that don't know this intrinsically, no value will be returned
val
- empty allocated array of type Double[] of size 1. val[0] will contain a Double object
with the scale value if available, other val[0] will contain nullpublic int SetOffset(double newoffset)
Very few formats implement this method. When not implemented it will issue a CPLE_NotSupported error and return CE_Failure.
newoffset
- the new offset.public int SetScale(double newscale)
Very few formats implement this method. When not implemented it will issue a CPLE_NotSupported error and return CE_Failure.
newscale
- the new scale.public int GetStatistics(int approx_ok, int force, double[] min, double[] max, double[] mean, double[] stddev)
Same as below but boolean value of true should be replaced with 1, and false with 0.
public int ComputeStatistics(boolean approx_ok, double[] min, double[] max, double[] mean, double[] stddev, ProgressCallback callback)
Returns the minimum, maximum, mean and standard deviation of all pixel values in this band. If approximate statistics are sufficient, the approx_ok flag can be set to true in which case overviews, or a subset of image tiles may be used in computing the statistics.
Once computed, the statistics will generally be "set" back on the raster band using SetStatistics().
approx_ok
- If true statistics may be computed based on overviews
or a subset of all tiles.min
- Allocated array of one double into which to load image minimum (may be null).max
- Allocated array of one double into which to load image maximum (may be null).mean
- Allocated array of one double into which to load image mean (may be null).stddev
- Allocated array of one double into which to load image standard deviation
(may be null).callback
- for reporting algorithm progress. May be nullpublic int ComputeStatistics(boolean approx_ok, double[] min, double[] max, double[] mean, double[] stddev)
Same as below with callback == null
ComputeStatistics(boolean approx_ok, double[] min, double[] max, double[] mean, double[] stddev, ProgressCallback callback)
public int ComputeStatistics(boolean approx_ok, double[] min, double[] max)
Same as below with mean == null, stddev == null and callback == null
ComputeStatistics(boolean approx_ok, double[] min, double[] max, double[] mean, double[] stddev, ProgressCallback callback)
public int ComputeStatistics(boolean approx_ok)
Same as below with min == null, max == null, mean == null, stddev == null and callback == null
ComputeStatistics(boolean approx_ok, double[] min, double[] max, double[] mean, double[] stddev, ProgressCallback callback)
public int SetStatistics(double min, double max, double mean, double stddev)
This method can be used to store min/max/mean/standard deviation statistics on a raster band.
The default implementation stores them as metadata, and will only work on formats that can save arbitrary metadata. This method cannot detect whether metadata will be properly saved and so may return CE_None even if the statistics will never be saved.
min
- minimum pixel value.max
- maximum pixel value.mean
- mean (average) of all pixel values.stddev
- Standard deviation of all pixel values.public int GetOverviewCount()
public Band GetOverview(int i)
i
- overview index between 0 and GetOverviewCount()-1.public int Checksum(int xoff, int yoff, int xsize, int ysize)
Computes a 16bit (0-65535) checksum from a region of raster data on the raster band. Floating point data is converted to 32bit integer so decimal portions of such raster data will not affect the checksum. Real and Imaginary components of complex bands influence the result.
xoff
- pixel offset of window to read.yoff
- line offset of window to read.xsize
- pixel size of window to read.ysize
- line size of window to read.public void ComputeRasterMinMax(double[] minMaxArray, int approx_ok)
If approximate is OK, then the band's GetMinimum()/GetMaximum() will be trusted. If it doesn't work, a subsample of blocks will be read to get an approximate min/max. If the band has a nodata value it will be excluded from the minimum and maximum.
If approx_ok is 0, then all pixels will be read and used to compute an exact range.
minMaxArray
- the allocated array of 2 doubles in which the minimum (minMaxArray[0]) and the
maximum (minMaxArray[1]) are returned.approx_ok
- 1 if an approximate (faster) answer is OK, otherwise 0.public void ComputeRasterMinMax(double[] minMaxArray)
Same as below with approx_ok == 0
ComputeRasterMinMax(double[] minMaxArray, int approx_ok)
public void ComputeBandStats(double[] meanAndStdDevArray, int samplestep)
meanAndStdDevArray
- the allocated array of 2 doubles in which the mean value (meanAndStdDevArray[0])
and the standard deviation (meanAndStdDevArray[1]) are returnedsamplestep
- step in number of linespublic void ComputeBandStats(double[] meanAndStdDevArray)
Same as below with samplestep == 1
ComputeBandStats(double[] meanAndStdDevArray, int samplestep)
public int Fill(double real_fill, double imag_fill)
GDAL makes no guarantees about what values pixels in newly created files are set to, so this method can be used to clear a band to a specified "default" value. The fill value is passed in as a double but this will be converted to the underlying type before writing to the file. An optional second argument allows the imaginary component of a complex constant value to be specified.
real_fill
- Real component of fill valueimag_fill
- Imaginary component of fill value, defaults to zeropublic int Fill(double real_fill)
Same as below with image_fill == 0
Fill(double real_fill, double imag_fill)
public void FlushCache()
This call will recover memory used to cache data blocks for this raster band, and ensure that new requests are referred to the underlying driver.
public ColorTable GetRasterColorTable()
If there is no associated color table, the return result is null. The returned color table remains owned by the Band object. It should not be modified by the caller.
public ColorTable GetColorTable()
If there is no associated color table, the return result is null. The returned color table remains owned by the Band object. It should not be modified by the caller.
public int SetRasterColorTable(ColorTable colorTable)
colorTable
- the color table to apply. This may be null to clear the color
table (where supported).public int SetColorTable(ColorTable colorTable)
colorTable
- the color table to apply. This may be null to clear the color
table (where supported).public RasterAttributeTable GetDefaultRAT()
A RAT will be returned if there is a default one associated with the band, otherwise null is returned. The returned RAT is owned by the band and should not be altered by the application.
public int SetDefaultRAT(RasterAttributeTable table)
Associates a default RAT with the band. If not implemented for the format a CPLE_NotSupported error will be issued.
table
- the RAT to assign to the band.public Band GetMaskBand()
The GDALRasterBand class includes a default implementation of GetMaskBand() that returns one of four default implementations :
Note that the GetMaskBand() should always return a GDALRasterBand mask, even if it is only an all 255 mask with the flags indicating GMF_ALL_VALID.
public int GetMaskFlags()
The GetMaskFlags() method returns an bitwise OR-ed set of status flags with the following available definitions that may be extended in the future:
The GDALRasterBand class includes a default implementation of GetMaskBand() that returns one of four default implementations :
public int CreateMaskBand(int nFlags)
The default implementation of the CreateMaskBand() method is implemented based on similar rules to the .ovr handling implemented using the GDALDefaultOverviews object. A TIFF file with the extension .msk will be created with the same basename as the original file, and it will have as many bands as the original image (or just one for GMF_PER_DATASET). The mask images will be deflate compressed tiled images with the same block size as the original image if possible.
public int SetDefaultHistogram(double min, double max, int[] histogram)
public boolean HasArbitraryOverviews()
This returns true if the underlying datastore can compute arbitrary overviews efficiently, such as is the case with OGDI over a network. Datastores with arbitrary overviews don't generally have any fixed overviews, but the ReadRaster() method can be used in downsampling mode to get overview data efficiently.
public Vector GetCategoryNames()
Raster values without associated names will have an empty string in the returned list. The first entry in the list is for raster values of zero, and so on.
public int SetCategoryNames(Vector names)
See the GetCategoryNames() method for more on the interpretation of category names.
names
- a vector of strings with category names. May
be ,ull to just clear the existing list.public int ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, ByteBuffer nioBuffer, int nPixelSpace, int nLineSpace)
This method allows reading a region of a GDALRasterBand into a buffer. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).
The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.
Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.
For highest performance full resolution data access, read on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the ReadBlock(int, int, java.nio.ByteBuffer) method.
When requesting a multi-byte datatype (GDT_Int16, GDT_Int32, GDT_Float32, ...), you should generally set the byte order of the buffer to the native order of the machine with nioBuffer.order(ByteOrder.nativeOrder()) (the default is BIG_ENDIAN) if you use the getShort(), getInt(), getFloat() etc... methods of the ByteBuffer class.
xoff
- The pixel offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the left side.yoff
- The line offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the top.xsize
- The width of the region of the band to be accessed in pixels.ysize
- The height of the region of the band to be accessed in lines.buf_xsize
- the width of the buffer image into which the desired region is
to be read, or from which it is to be written.buf_ysize
- the height of the buffer image into which the desired region is
to be read, or from which it is to be written.buf_type
- the type of the pixel values in the nioBuffer data buffer. One of
gdalconstConstants.GDT_Byte,
gdalconstConstants.GDT_Int16, ...
The pixel values will automatically be translated to/from the GDALRasterBand
data type as needed.nioBuffer
- The buffer into which the data should be read.
This buffer must contain at least buf_xsize *
buf_ysize words of type buf_type. It is organized in left to right,
top to bottom pixel order. Spacing is controlled by the nPixelSpace,
and nLineSpace parameters.nPixelSpace
- The byte offset from the start of one pixel value in
the buffer to the start of the next pixel value within a scanline. If defaulted
(0) the size of the datatype buf_type is used.nLineSpace
- The byte offset from the start of one scanline in
the buffer to the start of the next. If defaulted the size of the datatype
buf_type * buf_xsize is used.public int ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, ByteBuffer nioBuffer)
Same as below with nPixelSpace == 0 and nLineSpace == 0
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
This method allows reading a region of a GDALRasterBand into a buffer. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).
The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.
Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.
For highest performance full resolution data access, read on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the ReadBlock(int, int, java.nio.ByteBuffer) method.
xoff
- The pixel offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the left side.yoff
- The line offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the top.xsize
- The width of the region of the band to be accessed in pixels.ysize
- The height of the region of the band to be accessed in lines.buf_xsize
- the width of the buffer image into which the desired region is
to be read, or from which it is to be written.buf_ysize
- the height of the buffer image into which the desired region is
to be read, or from which it is to be written.buf_type
- the type of the pixel values in the array. One of
gdalconstConstants.GDT_Byte,
gdalconstConstants.GDT_Int16, ...
The pixel values will automatically be translated to/from the Band
data type as needed. The GDAL type must be consistant with the type of the Java array.array
- The buffer into which the data should be read.
This buffer must contain at least buf_xsize *
buf_ysize words of type buf_type. It is organized in left to right,
top to bottom pixel order. Spacing is controlled by the nPixelSpace,
and nLineSpace parameters.nPixelSpace
- The byte offset from the start of one pixel value in
the buffer to the start of the next pixel value within a scanline. If defaulted
(0) the size of the datatype buf_type is used.nLineSpace
- The byte offset from the start of one scanline in
the buffer to the start of the next. If defaulted the size of the datatype
buf_type * buf_xsize is used.public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
ReadRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, ByteBuffer nioBuffer, int nPixelSpace, int nLineSpace)
This method allows writing data from a buffer into a region of the Band. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).
The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.
Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.
For highest performance full resolution data access, write on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the WriteBlock(int, int, java.nio.ByteBuffer) method.
Before writing into a multi-byte datatype buffer (GDT_Int16, GDT_Int32, GDT_Float32, ...), you should generally set the byte order of the buffer to the native order of the machine with nioBuffer.order(ByteOrder.nativeOrder()) (the default is BIG_ENDIAN) if you use the putShort(), putInt(), putFloat(), ... methods of the ByteBuffer class.
xoff
- The pixel offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the left side.yoff
- The line offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the top.xsize
- The width of the region of the band to be accessed in pixels.ysize
- The height of the region of the band to be accessed in lines.buf_xsize
- the width of the buffer image from which the desired region is to be written.buf_ysize
- the height of the buffer image from which the desired region is to be written.buf_type
- the type of the pixel values in the nioBuffer data buffer. One of
gdalconstConstants.GDT_Byte,
gdalconstConstants.GDT_Int16, ...
The pixel values will automatically be translated to/from the GDALRasterBand
data type as needed.nioBuffer
- The buffer into which the data should be read.
This buffer must contain at least buf_xsize *
buf_ysize words of type buf_type. It is organized in left to right,
top to bottom pixel order. Spacing is controlled by the nPixelSpace,
and nLineSpace parameters.nPixelSpace
- The byte offset from the start of one pixel value in
the buffer to the start of the next pixel value within a scanline. If defaulted
(0) the size of the datatype buf_type is used.nLineSpace
- The byte offset from the start of one scanline in
the buffer to the start of the next. If defaulted the size of the datatype
buf_type * buf_xsize is used.public int WriteRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, ByteBuffer nioBuffer)
Same as below with nPixelSpace == 0 and nLineSpace == 0
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
This method allows writing data from a buffer into a region of the Band. It automatically takes care of data type translation if the data type (buf_type) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (buf_xsize x buf_ysize) is different than the size of the region being accessed (xsize x ysize).
The nPixelSpace and nLineSpace parameters allow reading into or writing from unusually organized buffers. This is primarily used for buffers containing more than one bands raster data in interleaved format.
Some formats may efficiently implement decimation into a buffer by reading from lower resolution overview images.
For highest performance full resolution data access, write on "block boundaries" as returned by GetBlockSize(int[], int[]), or use the WriteBlock(int, int, java.nio.ByteBuffer) method.
xoff
- The pixel offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the left side.yoff
- The line offset to the top left corner of the region
of the band to be accessed. This would be zero to start from the top.xsize
- The width of the region of the band to be accessed in pixels.ysize
- The height of the region of the band to be accessed in lines.buf_xsize
- the width of the buffer image from which the desired region is to be written.buf_ysize
- the height of the buffer image from which the desired region is to be written.buf_type
- the type of the pixel values in the array. One of
gdalconstConstants.GDT_Byte,
gdalconstConstants.GDT_Int16, ...
The pixel values will automatically be translated to/from the Band
data type as needed. The GDAL type must be consistant with the type of the Java array.array
- The buffer into which the data should be read.
This buffer must contain at least buf_xsize *
buf_ysize words of type buf_type. It is organized in left to right,
top to bottom pixel order. Spacing is controlled by the nPixelSpace,
and nLineSpace parameters.nPixelSpace
- The byte offset from the start of one pixel value in
the buffer to the start of the next pixel value within a scanline. If defaulted
(0) the size of the datatype buf_type is used.nLineSpace
- The byte offset from the start of one scanline in
the buffer to the start of the next. If defaulted the size of the datatype
buf_type * buf_xsize is used.public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, short[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, int[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, float[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, byte[] array, int nPixelSpace, int nLineSpace)
public int WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array)
Same as below with nPixelSpace == 0 and nLineSpace == 0
WriteRaster(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, double[] array, int nPixelSpace, int nLineSpace)
public int ReadBlock_Direct(int nXBlockOff, int nYBlockOff, ByteBuffer nioBuffer)
This method accesses a "natural" block from the raster band without resampling, or data type conversion. For a more generalized, but potentially less efficient access use ReadRaster().
nXBlockOff
- the horizontal block offset, with zero indicating
the left most block, 1 the next block and so forth.nYBlockOff
- the vertical block offset, with zero indicating
the left most block, 1 the next block and so forth.nioBuffer
- the buffer into which the data will be read. The buffer
must be large enough to hold GetBlockXSize()*GetBlockYSize() words
of type GetRasterDataType().public int WriteBlock_Direct(int nXBlockOff, int nYBlockOff, ByteBuffer nioBuffer)
This method accesses a "natural" block from the raster band without resampling, or data type conversion. For a more generalized, but potentially less efficient access use WriteRaster().
nXBlockOff
- the horizontal block offset, with zero indicating
the left most block, 1 the next block and so forth.nYBlockOff
- the vertical block offset, with zero indicating
the left most block, 1 the next block and so forth.nioBuffer
- the buffer from which the data will be written. The buffer
must be large enough to hold GetBlockXSize()*GetBlockYSize() words
of type GetRasterDataType().public int GetHistogram(double min, double max, int[] histogram, boolean include_out_of_range, boolean approx_ok, ProgressCallback callback)
Note that the bucket size is (dfMax-dfMin) / nBuckets.
For example to compute a simple 256 entry histogram of eight bit data, the following would be suitable. The unusual bounds are to ensure that bucket boundaries don't fall right on integer values causing possible errors due to rounding after scaling.
int anHistogram = new int[256]; band.GetHistogram( -0.5, 255.5, 256, anHistogram, false, false, null);
Note that setting approx_ok will generally result in a subsampling of the file, and will utilize overviews if available. It should generally produce a representative histogram for the data that is suitable for use in generating histogram based luts for instance. Generally bApproxOK is much faster than an exactly computed histogram.
min
- the lower bound of the histogram.max
- the upper bound of the histogram.histogram
- allocated array into which the histogram totals are placed.include_out_of_range
- if true values below the histogram range will
mapped into anHistogram[0], and values above will be mapped into
anHistogram[anHistogram.length-1] otherwise out of range values are discarded.approx_ok
- true if an approximate, or incomplete histogram OK.callback
- for reporting algorithm progress. May be nullpublic int GetHistogram(double min, double max, int[] histogram, boolean include_out_of_range, boolean approx_ok)
Same as below with callback == null
GetHistogram(double min, double max, int[] histogram, boolean include_out_of_range, boolean approx_ok, ProgressCallback callback)
public int GetHistogram(double min, double max, int[] histogram)
Same as below with include_out_of_range == 0, approx_ok == true and callback == null
GetHistogram(double min, double max, int[] histogram, boolean include_out_of_range, boolean approx_ok, ProgressCallback callback)
public int GetHistogram(int[] histogram)
Same as below with include_out_of_range == 0, approx_ok == true and callback == null
GetHistogram(double min, double max, int[] histogram, boolean include_out_of_range, boolean approx_ok, ProgressCallback callback)
public int GetDefaultHistogram(double[] min_ret, double[] max_ret, int[][] histogram_ret, boolean force, ProgressCallback callback)
The default method in GDALRasterBand will compute a default histogram. This method is overriden by derived classes (such as GDALPamRasterBand, VRTDataset, HFADataset...) that may be able to fetch efficiently an already stored histogram.
For example,
double[] dfMin = new double[1]; double[] dfMax = new double[1]; int[][] panHistogram = new int[1][]; int eErr = hBand.GetDefaultHistogram(dfMin, dfMax, panHistogram, true, new TermProgressCallback()); if( eErr == gdalconst.CE_None ) { int iBucket; int nBucketCount = panHistogram[0].length; System.out.print( " " + nBucketCount + " buckets from " + dfMin[0] + " to " + dfMax[0] + ":\n " ); for( iBucket = 0; iBucket < nBucketCount; iBucket++ ) System.out.print( panHistogram[0][iBucket] + " "); System.out.print( "\n" ); }
min_ret
- allocated array of one double that will contain the lower bound of the histogram.max_ret
- allocated array of one double that will contain the upper bound of the histogram.histogram_ret
- allocated array of one int[] into which the histogram totals are placed.force
- true to force the computation. If false and no default histogram is available, the method will return CE_Warningcallback
- for reporting algorithm progress. May be nullpublic int GetDefaultHistogram(double[] min_ret, double[] max_ret, int[][] histogram_ret, boolean force)
Same as below with callback == null
GetDefaultHistogram(double[] min_ret, double[] max_ret, int[][] histogram_ret, boolean force, ProgressCallback callback)
public int GetDefaultHistogram(double[] min_ret, double[] max_ret, int[][] histogram_ret)
Same as below with force == true and callback == null
GetDefaultHistogram(double[] min_ret, double[] max_ret, int[][] histogram_ret, boolean force, ProgressCallback callback)