QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
Iterator for sequentially processing raster cells. More...
#include <qgsrasteriterator.h>
Public Member Functions | |
QgsRasterIterator (QgsRasterInterface *input) | |
Constructor for QgsRasterIterator, iterating over the specified input raster source. More... | |
const QgsRasterInterface * | input () const |
Returns the input raster interface which is being iterated over. More... | |
int | maximumTileHeight () const |
Returns the minimum tile width returned during iteration. More... | |
int | maximumTileWidth () const |
Returns the maximum tile width returned during iteration. More... | |
bool | next (int bandNumber, int &columns, int &rows, int &topLeftColumn, int &topLeftRow, QgsRectangle &blockExtent) |
Fetches details of the next part of the raster data. More... | |
bool | readNextRasterPart (int bandNumber, int &nCols, int &nRows, QgsRasterBlock **block, int &topLeftCol, int &topLeftRow) |
Fetches next part of raster data, caller takes ownership of the block and caller should delete the block. More... | |
bool | readNextRasterPart (int bandNumber, int &nCols, int &nRows, std::unique_ptr< QgsRasterBlock > &block, int &topLeftCol, int &topLeftRow, QgsRectangle *blockExtent=nullptr) |
Fetches next part of raster data. More... | |
void | setMaximumTileHeight (int h) |
Sets the minimum tile height returned during iteration. More... | |
void | setMaximumTileWidth (int w) |
Sets the maximum tile width returned during iteration. More... | |
void | startRasterRead (int bandNumber, int nCols, int nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback=nullptr) |
Start reading of raster band. More... | |
void | stopRasterRead (int bandNumber) |
Cancels the raster iteration and resets the iterator. More... | |
Static Public Attributes | |
static const int | DEFAULT_MAXIMUM_TILE_HEIGHT = 2000 |
Default maximum tile height. More... | |
static const int | DEFAULT_MAXIMUM_TILE_WIDTH = 2000 |
Default maximum tile width. More... | |
Iterator for sequentially processing raster cells.
Definition at line 34 of file qgsrasteriterator.h.
QgsRasterIterator::QgsRasterIterator | ( | QgsRasterInterface * | input | ) |
Constructor for QgsRasterIterator, iterating over the specified input raster source.
Definition at line 21 of file qgsrasteriterator.cpp.
|
inline |
Returns the input raster interface which is being iterated over.
Definition at line 117 of file qgsrasteriterator.h.
|
inline |
Returns the minimum tile width returned during iteration.
Definition at line 145 of file qgsrasteriterator.h.
|
inline |
Returns the maximum tile width returned during iteration.
Definition at line 131 of file qgsrasteriterator.h.
bool QgsRasterIterator::next | ( | int | bandNumber, |
int & | columns, | ||
int & | rows, | ||
int & | topLeftColumn, | ||
int & | topLeftRow, | ||
QgsRectangle & | blockExtent | ||
) |
Fetches details of the next part of the raster data.
This method does NOT actually fetch the raster data itself, rather it calculates and iterates over the details of the raster alone.
It's useful for iterating over several layers using a target "reference" layer. E.g. summing the pixels in n rasters whilst aligning the result to a reference layer which is not being summed.
Note that calling this method also advances the iterator, just like calling readNextRasterPart().
bandNumber | band to read |
columns | number of columns on output device |
rows | number of rows on output device |
topLeftColumn | top left column |
topLeftRow | top left row |
blockExtent | exact extent of returned raster block |
false
if the last part was already returnedDefinition at line 60 of file qgsrasteriterator.cpp.
bool QgsRasterIterator::readNextRasterPart | ( | int | bandNumber, |
int & | nCols, | ||
int & | nRows, | ||
QgsRasterBlock ** | block, | ||
int & | topLeftCol, | ||
int & | topLeftRow | ||
) |
Fetches next part of raster data, caller takes ownership of the block and caller should delete the block.
bandNumber | band to read |
nCols | number of columns on output device |
nRows | number of rows on output device |
block | address of block pointer |
topLeftCol | top left column |
topLeftRow | top left row |
false
if the last part was already returned Definition at line 65 of file qgsrasteriterator.cpp.
bool QgsRasterIterator::readNextRasterPart | ( | int | bandNumber, |
int & | nCols, | ||
int & | nRows, | ||
std::unique_ptr< QgsRasterBlock > & | block, | ||
int & | topLeftCol, | ||
int & | topLeftRow, | ||
QgsRectangle * | blockExtent = nullptr |
||
) |
Fetches next part of raster data.
bandNumber | band to read |
nCols | number of columns on output device |
nRows | number of rows on output device |
block | address of block pointer |
topLeftCol | top left column |
topLeftRow | top left row |
blockExtent | optional storage for exact extent of returned raster block |
false
if the last part was already returned Definition at line 78 of file qgsrasteriterator.cpp.
|
inline |
Sets the minimum tile height returned during iteration.
Definition at line 138 of file qgsrasteriterator.h.
|
inline |
Sets the maximum tile width returned during iteration.
Definition at line 124 of file qgsrasteriterator.h.
void QgsRasterIterator::startRasterRead | ( | int | bandNumber, |
int | nCols, | ||
int | nRows, | ||
const QgsRectangle & | extent, | ||
QgsRasterBlockFeedback * | feedback = nullptr |
||
) |
Start reading of raster band.
Raster data can then be retrieved by calling readNextRasterPart until it returns false
.
bandNumber | number of raster band to read |
nCols | number of columns |
nRows | number of rows |
extent | area to read |
feedback | optional raster feedback object for cancellation/preview. Added in QGIS 3.0. |
Definition at line 38 of file qgsrasteriterator.cpp.
void QgsRasterIterator::stopRasterRead | ( | int | bandNumber | ) |
Cancels the raster iteration and resets the iterator.
Definition at line 148 of file qgsrasteriterator.cpp.
|
static |
Default maximum tile height.
Definition at line 151 of file qgsrasteriterator.h.
|
static |
Default maximum tile width.
Definition at line 148 of file qgsrasteriterator.h.