Iterator for sequentially processing raster cells.
More...
#include <qgsrasteriterator.h>
|
| 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, qgssize nCols, qgssize 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 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. More...
|
|
Iterator for sequentially processing raster cells.
Definition at line 34 of file qgsrasteriterator.h.
◆ QgsRasterIterator()
◆ input()
Returns the input raster interface which is being iterated over.
Definition at line 136 of file qgsrasteriterator.h.
◆ maximumTileHeight()
int QgsRasterIterator::maximumTileHeight |
( |
| ) |
const |
|
inline |
◆ maximumTileWidth()
int QgsRasterIterator::maximumTileWidth |
( |
| ) |
const |
|
inline |
◆ next()
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().
- Parameters
-
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 |
- Returns
false
if the last part was already returned
- Since
- QGIS 3.6
Definition at line 99 of file qgsrasteriterator.cpp.
◆ readNextRasterPart() [1/2]
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
Definition at line 104 of file qgsrasteriterator.cpp.
◆ readNextRasterPart() [2/2]
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.
- 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
- Note
- Not available in Python bindings
- Since
- QGIS 3.2
Definition at line 117 of file qgsrasteriterator.cpp.
◆ setMaximumTileHeight()
void QgsRasterIterator::setMaximumTileHeight |
( |
int |
h | ) |
|
|
inline |
◆ setMaximumTileWidth()
void QgsRasterIterator::setMaximumTileWidth |
( |
int |
w | ) |
|
|
inline |
◆ startRasterRead()
Start reading of raster band.
Raster data can then be retrieved by calling readNextRasterPart until it returns false
.
- 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 cancellation/preview. Added in QGIS 3.0. |
Definition at line 77 of file qgsrasteriterator.cpp.
◆ stopRasterRead()
void QgsRasterIterator::stopRasterRead |
( |
int |
bandNumber | ) |
|
◆ subRegion()
QgsRectangle QgsRasterIterator::subRegion |
( |
const QgsRectangle & |
rasterExtent, |
|
|
int |
rasterWidth, |
|
|
int |
rasterHeight, |
|
|
const QgsRectangle & |
subRegion, |
|
|
int & |
subRegionWidth, |
|
|
int & |
subRegionHeight, |
|
|
int & |
subRegionLeft, |
|
|
int & |
subRegionTop |
|
) |
| |
|
static |
Given an overall raster extent and width and height in pixels, calculates the sub region of the raster covering the specified subRegion.
- Parameters
-
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 |
- Returns
- sub region geographic extent, snapped to exact pixel boundaries
- Since
- QGIS 3.26
Definition at line 38 of file qgsrasteriterator.cpp.
◆ DEFAULT_MAXIMUM_TILE_HEIGHT
const int QgsRasterIterator::DEFAULT_MAXIMUM_TILE_HEIGHT = 2000 |
|
static |
◆ DEFAULT_MAXIMUM_TILE_WIDTH
const int QgsRasterIterator::DEFAULT_MAXIMUM_TILE_WIDTH = 2000 |
|
static |
The documentation for this class was generated from the following files: