Class: QgsRasterCalculator

class qgis.analysis.QgsRasterCalculator(formulaString: str, outputFile: str, outputFormat: str, outputExtent: QgsRectangle, nOutputColumns: int, nOutputRows: int, rasterEntries: object)

Bases: sip.wrapper

QgsRasterCalculator constructor.

Parameters
  • formulaString – formula for raster calculation

  • outputFile – output file path

  • outputFormat – output file format

  • outputExtent – output extent. CRS for output is taken from first entry in rasterEntries.

  • nOutputColumns – number of columns in output raster

  • nOutputRows – number of rows in output raster

  • rasterEntries – list of referenced raster layers

QgsRasterCalculator(formulaString: str, outputFile: str, outputFormat: str, outputExtent: QgsRectangle, outputCrs: QgsCoordinateReferenceSystem, nOutputColumns: int, nOutputRows: int, rasterEntries: Iterable[QgsRasterCalculatorEntry]) QgsRasterCalculator constructor.

Parameters
  • formulaString – formula for raster calculation

  • outputFile – output file path

  • outputFormat – output file format

  • outputExtent – output extent, CRS is specified by outputCrs parameter

  • outputCrs – destination CRS for output raster

  • nOutputColumns – number of columns in output raster

  • nOutputRows – number of rows in output raster

  • rasterEntries – list of referenced raster layers

New in version 2.10.

QgsRasterCalculator(QgsRasterCalculator)

Performs raster layer calculations.

Enums

Methods

lastError

Returns a description of the last error encountered.

processCalculation

Starts the calculation and writes a new raster.

Signals

Attributes

BandError

Canceled

CreateOutputError

InputLayerError

MemoryError

ParserError

Success

BandError = 6
Canceled = 3
CreateOutputError = 1
InputLayerError = 2
MemoryError = 5
ParserError = 4
class Result

Bases: int

Success = 0
lastError(self) → str

Returns a description of the last error encountered.

New in version 3.4.

processCalculation(self, feedback: QgsFeedback = None) → QgsRasterCalculator.Result

Starts the calculation and writes a new raster.

The optional feedback argument can be used for progress reporting and cancellation support.

Returns

QgsRasterCalculator.Success in case of success. If an error is encountered then a description of the error can be obtained by calling lastError().