Subgroup: Raster

Class: QgsRasterIterator

class qgis.core.QgsRasterIterator(input: QgsRasterInterface)

Bases: sip.wrapper

Constructor for QgsRasterIterator, iterating over the specified input raster source.

QgsRasterIterator(QgsRasterIterator)

Iterator for sequentially processing raster cells.

Methods

input Returns the input raster interface which is being iterated over.
maximumTileHeight Returns the minimum tile width returned during iteration.
maximumTileWidth Returns the maximum tile width returned during iteration.
readNextRasterPart Fetches next part of raster data, caller takes ownership of the block and caller should delete the block.
setMaximumTileHeight Sets the minimum tile height returned during iteration.
setMaximumTileWidth Sets the maximum tile width returned during iteration.
startRasterRead Start reading of raster band.
stopRasterRead Cancels the raster iteration and resets the iterator.

Signals

Attributes

DEFAULT_MAXIMUM_TILE_HEIGHT
DEFAULT_MAXIMUM_TILE_WIDTH
DEFAULT_MAXIMUM_TILE_HEIGHT = 2000
DEFAULT_MAXIMUM_TILE_WIDTH = 2000
input(self) → QgsRasterInterface

Returns the input raster interface which is being iterated over.

maximumTileHeight(self) → int

Returns the minimum tile width returned during iteration.

maximumTileWidth(self) → int

Returns the maximum tile width returned during iteration.

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 – 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

setMaximumTileHeight(self, h: int)

Sets the minimum tile height returned during iteration.

setMaximumTileWidth(self, w: int)

Sets the maximum tile width returned during iteration.

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 – 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.
stopRasterRead(self, bandNumber: int)

Cancels the raster iteration and resets the iterator.