QGIS API Documentation 3.39.0-Master (9ea1ddbe645)
|
Iterator for sequentially processing raster cells. More...
#include <qgsrasteriterator.h>
Public Member Functions | |
QgsRasterIterator (QgsRasterInterface *input, int tileOverlapPixels=0) | |
Constructor for QgsRasterIterator, iterating over the specified input raster source. | |
const QgsRasterInterface * | input () const |
Returns the input raster interface which is being iterated over. | |
int | maximumTileHeight () const |
Returns the minimum tile width returned during iteration. | |
int | maximumTileWidth () const |
Returns the maximum tile width returned during iteration. | |
bool | next (int bandNumber, int &columns, int &rows, int &topLeftColumn, int &topLeftRow, QgsRectangle &blockExtent) |
Fetches details of the next part of the raster data. | |
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. | |
bool | readNextRasterPart (int bandNumber, int &nCols, int &nRows, std::unique_ptr< QgsRasterBlock > &block, int &topLeftCol, int &topLeftRow, QgsRectangle *blockExtent=nullptr, int *tileColumns=nullptr, int *tileRows=nullptr, int *tileTopLeftColumn=nullptr, int *tileTopLeftRow=nullptr) |
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, qgssize nCols, qgssize nRows, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback=nullptr) |
Start reading of raster band. | |
void | stopRasterRead (int bandNumber) |
Cancels the raster iteration and resets the iterator. | |
Static Public Member Functions | |
static QgsRectangle | subRegion (const QgsRectangle &rasterExtent, int rasterWidth, int rasterHeight, const QgsRectangle &subRegion, int &subRegionWidth, int &subRegionHeight, int &subRegionLeft, int &subRegionTop) |
Given an overall raster extent and width and height in pixels, calculates the sub region of the raster covering the specified subRegion. | |
Static Public Attributes | |
static const int | DEFAULT_MAXIMUM_TILE_HEIGHT = 2000 |
Default maximum tile height. | |
static const int | DEFAULT_MAXIMUM_TILE_WIDTH = 2000 |
Default maximum tile width. | |
Iterator for sequentially processing raster cells.
Definition at line 34 of file qgsrasteriterator.h.
QgsRasterIterator::QgsRasterIterator | ( | QgsRasterInterface * | input, |
int | tileOverlapPixels = 0 |
||
) |
Constructor for QgsRasterIterator, iterating over the specified input raster source.
Since QGIS 3.34 the tileOverlapPixels can be used to specify a margin in pixels for retrieving pixels overlapping into neighbor cells.
Definition at line 19 of file qgsrasteriterator.cpp.
|
inline |
Returns the input raster interface which is being iterated over.
Definition at line 143 of file qgsrasteriterator.h.
|
inline |
Returns the minimum tile width returned during iteration.
Definition at line 171 of file qgsrasteriterator.h.
|
inline |
Returns the maximum tile width returned during iteration.
Definition at line 157 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 98 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 107 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 , |
||
int * | tileColumns = nullptr , |
||
int * | tileRows = nullptr , |
||
int * | tileTopLeftColumn = nullptr , |
||
int * | tileTopLeftRow = 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 |
tileColumns | optional storage for number of columns in the iterated tile (excluding any tile overlap pixels) |
tileRows | optional storage for number of rows in the iterated tile (excluding any tile overlap pixels) |
tileTopLeftColumn | optional storage for the top left column in the iterated tile (excluding any tile overlap pixels) |
tileTopLeftRow | optional storage for the top left row in the iterated tile (excluding any tile overlap pixels) |
false
if the last part was already returned Definition at line 120 of file qgsrasteriterator.cpp.
|
inline |
Sets the minimum tile height returned during iteration.
Definition at line 164 of file qgsrasteriterator.h.
|
inline |
Sets the maximum tile width returned during iteration.
Definition at line 150 of file qgsrasteriterator.h.
void QgsRasterIterator::startRasterRead | ( | int | bandNumber, |
qgssize | nCols, | ||
qgssize | 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 76 of file qgsrasteriterator.cpp.
void QgsRasterIterator::stopRasterRead | ( | int | bandNumber | ) |
Cancels the raster iteration and resets the iterator.
Definition at line 219 of file qgsrasteriterator.cpp.
|
static |
Given an overall raster extent and width and height in pixels, calculates the sub region of the raster covering the specified subRegion.
rasterExtent | overall raster extent |
rasterWidth | overall raster width |
rasterHeight | overall raster height |
subRegion | desired sub region extent |
subRegionWidth | width in pixels of sub region |
subRegionHeight | height in pixels of sub region |
subRegionLeft | starting column of left side of sub region |
subRegionTop | starting row of top side of sub region |
Definition at line 37 of file qgsrasteriterator.cpp.
|
static |
Default maximum tile height.
Definition at line 177 of file qgsrasteriterator.h.
|
static |
Default maximum tile width.
Definition at line 174 of file qgsrasteriterator.h.