QgsRasterIterator class

Iterator for sequentially processing raster cells.

Public static variables

static const int DEFAULT_MAXIMUM_TILE_HEIGHT
Default maximum tile height.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.

Constructors, destructors, conversion operators

QgsRasterIterator(QgsRasterInterface* input)
Constructor for QgsRasterIterator, iterating over the specified input raster source.

Public functions

auto input() const -> const QgsRasterInterface*
Returns the input raster interface which is being iterated over.
auto maximumTileHeight() const -> int
Returns the minimum tile width returned during iteration.
auto maximumTileWidth() const -> int
Returns the maximum tile width returned during iteration.
auto readNextRasterPart(int bandNumber, int& nCols, int& nRows, QgsRasterBlock** block, int& topLeftCol, int& topLeftRow) -> bool
Fetches next part of raster data, caller takes ownership of the block and caller should delete the block.
auto readNextRasterPart(int bandNumber, int& nCols, int& nRows, std::unique_ptr<QgsRasterBlock>& block, int& topLeftCol, int& topLeftRow, QgsRectangle* blockExtent = nullptr) SIP_SKIP -> bool
Fetches next part of raster data.
void setMaximumTileHeight(int h)
Sets the minimum tile height returned during iteration.
void setMaximumTileWidth(int w)
Sets the maximum tile width returned during iteration.
void startRasterRead(int bandNumber, int nCols, int nRows, const QgsRectangle& extent, QgsRasterBlockFeedback* feedback = nullptr)
Start reading of raster band.
void stopRasterRead(int bandNumber)
Cancels the raster iteration and resets the iterator.

Function documentation

int QgsRasterIterator::maximumTileHeight() const

Returns the minimum tile width returned during iteration.

int QgsRasterIterator::maximumTileWidth() const

Returns the maximum tile width returned during iteration.

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.

Parameters
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
Returns false if the last part was already returned

bool QgsRasterIterator::readNextRasterPart(int bandNumber, int& nCols, int& nRows, std::unique_ptr<QgsRasterBlock>& block, int& topLeftCol, int& topLeftRow, QgsRectangle* blockExtent = nullptr) SIP_SKIP

Fetches next part of raster data.

Parameters
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
Returns false if the last part was already returned

void QgsRasterIterator::setMaximumTileHeight(int h)

Sets the minimum tile height returned during iteration.

void QgsRasterIterator::setMaximumTileWidth(int w)

Sets the maximum tile width returned during iteration.

void QgsRasterIterator::startRasterRead(int bandNumber, int nCols, int nRows, const QgsRectangle& extent, QgsRasterBlockFeedback* feedback = nullptr)

Start reading of raster band.

Parameters
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 cancelation/preview. Added in QGIS 3.0.

Raster data can then be retrieved by calling readNextRasterPart until it returns false.