Class: QgsRasterIterator¶
- class qgis.core.QgsRasterIterator¶
Bases:
sip.wrapper
Iterator for sequentially processing raster cells.
QgsRasterIterator(input:
QgsRasterInterface
) Constructor forQgsRasterIterator
, iterating over the specifiedinput
raster source.QgsRasterIterator(
QgsRasterIterator
)Methods
Returns the input raster interface which is being iterated over.
Returns the minimum tile width returned during iteration.
Returns the maximum tile width returned during iteration.
Fetches details of the next part of the raster data.
Fetches next part of raster data, caller takes ownership of the block and caller should delete the block.
Sets the minimum tile height returned during iteration.
Sets the maximum tile width returned during iteration.
Start reading of raster band.
Cancels the raster iteration and resets the iterator.
Attributes
- DEFAULT_MAXIMUM_TILE_HEIGHT = 2000¶
- DEFAULT_MAXIMUM_TILE_WIDTH = 2000¶
- input(self) QgsRasterInterface ¶
Returns the input raster interface which is being iterated over.
- Return type:
- maximumTileHeight(self) int ¶
Returns the minimum tile width returned during iteration.
See also
See also
- Return type:
int
- maximumTileWidth(self) int ¶
Returns the maximum tile width returned during iteration.
See also
See also
- Return type:
int
- next(self, bandNumber: int) Tuple[bool, int, int, int, int, QgsRectangle] ¶
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 (int) – band to read
- Return type:
Tuple[bool, int, int, int, int, QgsRectangle]
- Returns:
False
if the last part was already returnedcolumns: 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
New in version 3.6.
- readNextRasterPart(self, bandNumber: int) Tuple[bool, int, int, QgsRasterBlock, int, int] ¶
Fetches next part of raster data, caller takes ownership of the block and caller should delete the block.
- Parameters:
bandNumber (int) – 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
- Return type:
Tuple[bool, int, int,
QgsRasterBlock
, int, int]- Returns:
False
if the last part was already returned
- setMaximumTileHeight(self, h: int)¶
Sets the minimum tile height returned during iteration.
See also
See also
- Parameters:
h (int) –
- setMaximumTileWidth(self, w: int)¶
Sets the maximum tile width returned during iteration.
See also
See also
- Parameters:
w (int) –
- startRasterRead(self, bandNumber: int, nCols: int, nRows: int, extent: QgsRectangle, feedback: QgsRasterBlockFeedback = None)¶
Start reading of raster band. Raster data can then be retrieved by calling readNextRasterPart until it returns
False
.- Parameters:
bandNumber (int) – number of raster band to read
nCols (int) – number of columns
nRows (int) – number of rows
extent (QgsRectangle) – area to read
feedback (
QgsRasterBlockFeedback
= None) – optional raster feedback object for cancellation/preview. Added in QGIS 3.0.
- stopRasterRead(self, bandNumber: int)¶
Cancels the raster iteration and resets the iterator.
- Parameters:
bandNumber (int) –