#include <gdal_priv.h>
Inheritance diagram for GDALRasterBand:
Public Methods | |
GDALRasterBand () | |
virtual | ~GDALRasterBand () |
int | GetXSize () |
int | GetYSize () |
int | GetBand () |
GDALDataset* | GetDataset () |
GDALDataType | GetRasterDataType ( void ) |
void | GetBlockSize ( int *, int * ) |
GDALAccess | GetAccess () |
CPLErr | RasterIO ( GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int ) |
CPLErr | ReadBlock ( int, int, void * ) |
CPLErr | WriteBlock ( int, int, void * ) |
GDALRasterBlock* | GetBlockRef ( int, int ) |
CPLErr | FlushCache () |
CPLErr | FlushBlock ( int = -1, int = -1 ) |
virtual char** | GetCategoryNames () |
virtual double | GetNoDataValue ( int *pbSuccess = NULL ) |
virtual double | GetMinimum ( int *pbSuccess = NULL ) |
virtual double | GetMaximum (int *pbSuccess = NULL ) |
virtual double | GetOffset ( int *pbSuccess = NULL ) |
virtual double | GetScale ( int *pbSuccess = NULL ) |
virtual const char* | GetUnitType () |
virtual GDALColorInterp | GetColorInterpretation () |
virtual GDALColorTable* | GetColorTable () |
virtual CPLErr | SetCategoryNames ( char ** ) |
virtual CPLErr | SetNoDataValue ( double ) |
virtual CPLErr | SetColorTable ( GDALColorTable * ) |
virtual CPLErr | SetColorInterpretation ( GDALColorInterp ) |
virtual int | HasArbitraryOverviews () |
virtual int | GetOverviewCount () |
virtual GDALRasterBand* | GetOverview (int) |
virtual CPLErr | BuildOverviews ( const char *, int, int *, GDALProgressFunc, void * ) |
CPLErr | GetHistogram ( double dfMin, double dfMax, int nBuckets, int * panHistogram, int bIncludeOutOfRange, int bApproxOK, GDALProgressFunc, void *pProgressData ) |
Protected Methods | |
virtual CPLErr | IReadBlock ( int, int, void * ) = 0 |
virtual CPLErr | IWriteBlock ( int, int, void * ) |
virtual CPLErr | IRasterIO ( GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int ) |
CPLErr | OverviewRasterIO ( GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int ) |
CPLErr | AdoptBlock ( int, int, GDALRasterBlock * ) |
void | InitBlockInfo () |
Protected Attributes | |
GDALDataset* | poDS |
int | nBand |
int | nRasterXSize |
int | nRasterYSize |
GDALDataType | eDataType |
GDALAccess | eAccess |
int | nBlockXSize |
int | nBlockYSize |
int | nBlocksPerRow |
int | nBlocksPerColumn |
GDALRasterBlock** | papoBlocks |
Friends | |
class | GDALDataset |
class | GDALRasterBlock |
|
Constructor. Applications should never create GDALRasterBands directly. |
|
Destructor. Applications should never destroy GDALRasterBands directly, instead destroy the GDALDataset. |
|
Build raster overview(s) If the operation is unsupported for the indicated dataset, then CE_Failure is returned, and CPLGetLastError() will return CPLE_NonSupported.
|
|
Flush raster data cache. 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. This method is the same as the C function GDALFlushRasterCache().
|
|
Find out if we have update permission for this band.
|
|
Fetch the band number. This method returns the band that this GDALRasterBand objects represents within it's dataset. This method may return a value of 0 to indicate GDALRasterBand objects without an apparently relationship to a dataset, such as GDALRasterBands serving as overviews. There is currently no C analog to this method.
|
|
Fetch a pointer to an internally cached raster block. Note that calling GetBlockRef() on a previously uncached band will enable caching.
|
|
Fetch the "natural" block size of this band. 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 *pnXSize is set to GetXSize(), and *pnYSize 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() for an example of code dealing with these issues.
|
|
Fetch the list of category names for this raster. The return list is a "StringList" in the sense of the CPL functions. That is a NULL terminated array of strings. 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. The returned stringlist should not be altered or freed by the application. It may change on the next GDAL call, so please copy it if it is needed for any period of time.
|
|
How should this band be interpreted as color? CV_Undefined is returned when the format doesn't know anything about the color interpretation. This method is the same as the C function GDALGetRasterColorInterpretation().
|
|
Fetch the color table associated with band. If there is no associated color table, the return result is NULL. The returned color table remains owned by the GDALRasterBand, and can't be depended on for long, nor should it ever be modified by the caller. This method is the same as the C function GDALGetRasterColorTable().
|
|
Fetch the owning dataset handle. Note that some GDALRasterBands are not considered to be a part of a dataset, such as overviews or other "freestanding" bands. There is currently no C analog to this method.
|
|
Compute raster histogram. 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[256]; poBand->GetHistogram( -0.5, 255.5, 256, anHistogram, FALSE, FALSE, GDALDummyProgress, NULL ); Note that setting bApproxOK 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.
|
|
Fetch the maximum value for this band. For file formats that don't know this intrinsically, the maximum supported value for the data type will generally be returned. This method is the same as the C function GDALGetRasterMaximum().
|
|
Fetch the minimum value for this band. For file formats that don't know this intrinsically, the minimum supported value for the data type will generally be returned. This method is the same as the C function GDALGetRasterMinimum().
|
|
Fetch the no data value for this band. If there is no out of data value, an out of range value will generally be returned. 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. This method is the same as the C function GDALGetRasterNoDataValue().
|
|
Fetch the raster value offset. 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 a value of zero is returned.
|
|
Fetch overview raster band object. This method is the same as the C function GDALGetOverview().
|
|
Return the number of overview layers available. This method is the same as the C function GDALGetOverviewCount();
|
|
Fetch the pixel data type for this band.
|
|
Fetch the raster value scale. 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 a value of one is returned.
|
|
Return raster unit type. 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. The returned string should not be modified, nor freed by the calling application. This method is the same as the C function GDALGetRasterUnitType().
|
|
Fetch XSize of raster. This method is the same as the C function GDALGetRasterBandXSize().
|
|
Fetch YSize of raster. This method is the same as the C function GDALGetRasterBandYSize().
|
|
Check for arbitrary overviews. 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 RasterIO() method can be used in downsampling mode to get overview data efficiently. This method is the same as the C function GDALHasArbitraryOverviews(),
|
|
Read/write a region of image data for this band. This method allows reading a region of a GDALRasterBand into a buffer, or writing data from a buffer into a region of a GDALRasterBand. It automatically takes care of data type translation if the data type (eBufType) of the buffer is different than that of the GDALRasterBand. The method also takes care of image decimation / replication if the buffer size (nBufXSize x nBufYSize) is different than the size of the region being accessed (nXSize x nYSize). 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 and write on "block boundaries" as returned by GetBlockSize(), or use the ReadBlock() and WriteBlock() methods. This method is the same as the C GDALRasterIO() function.
|
|
Read a block of image data efficiently. 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 RasterIO(). This method is the same as the C GDALReadBlock() function. See the GetBlockRef() method for a way of accessing internally cached block oriented data without an extra copy into an application buffer.
CPLErr GetHistogram( GDALRasterBand *poBand, int *panHistogram ) { int nXBlocks, nYBlocks, nXBlockSize, nYBlockSize; int iXBlock, iYBlock; memset( panHistogram, 0, sizeof(int) * 256 ); CPLAssert( poBand->GetRasterDataType() == GDT_Byte ); poBand->GetBlockSize( &nXBlockSize, &nYBlockSize ); nXBlocks = (poBand->GetXSize() + nXBlockSize - 1) / nXBlockSize; nYBlocks = (poBand->GetYSize() + nYBlockSize - 1) / nYBlockSize; pabyData = (GByte *) CPLMalloc(nXBlockSize * nYBlockSize); for( iYBlock = 0; iYBlock < nYBlocks; iYBlock++ ) { for( iXBlock = 0; iXBlock < nXBlocks; iXBlock++ ) { int nXValid, nYValid; poBand->ReadBlock( iXBlock, iYBlock, pabyData ); // Compute the portion of the block that is valid // for partial edge blocks. if( iXBlock * nXBlockSize > poBand->GetXSize() ) nXValid = poBand->GetXSize() - iXBlock * nXBlockSize; else nXValid = nXBlockSize; if( iYBlock * nYBlockSize > poBand->GetYSize() ) nYValid = poBand->GetXSize() - iYBlock * nYBlockSize; else nYValid = nYBlockSize; // Collect the histogram counts. for( int iY = 0; iY < nXValid; iY++ ) { for( int iX = 0; iX < nXValid; iX++ ) { pabyHistogram[pabyData[iX + iY * nXBlockSize]] += 1; } } } } } |
|
Set the category names for this band. See the GetCategoryNames() method for more on the interpretation of category names. This method is the same as the C function GDALSetRasterCategoryNames().
|
|
Set color interpretation of a band.
|
|
Set the raster color table. The driver will make a copy of all desired data in the colortable. It remains owned by the caller after the call. This method is the same as the C function GDALSetRasterColorTable().
|
|
Set the no data value for this band. 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. This method is the same as the C function GDALSetRasterNoDataValue().
|
|
Write a block of image data efficiently. 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 RasterIO(). This method is the same as the C GDALWriteBlock() function. See ReadBlock() for an example of block oriented data access.
|