Class: QgsMeshCalculator

class qgis.core.QgsMeshCalculator(formulaString: str, outputFile: str, outputExtent: QgsRectangle, startTime: float, endTime: float, layer: QgsMeshLayer)

Bases: sip.wrapper

Creates calculator with bounding box (rectangular) mask

Parameters
  • formulaString (str) – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • outputFile (str) – file to store the resulting dataset group data

  • outputExtent (QgsRectangle) – spatial filter defined by rectangle

  • startTime (float) – time filter defining the starting dataset

  • endTime (float) – time filter defining the ending dataset

  • layer (QgsMeshLayer) – mesh layer with dataset groups references in formulaString

Deprecated since version QGIS: 3.12

QgsMeshCalculator(formulaString: str, outputFile: str, outputMask: QgsGeometry, startTime: float, endTime: float, layer: QgsMeshLayer) Creates calculator with geometry mask

Parameters
  • formulaString – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • outputFile – file to store the resulting dataset group data

  • outputMask – spatial filter defined by geometry

  • startTime – time filter defining the starting dataset

  • endTime – time filter defining the ending dataset

  • layer – mesh layer with dataset groups references in formulaString

Deprecated since version QGIS: 3.12

QgsMeshCalculator(formulaString: str, outputDriver: str, outputGroupName: str, outputFile: str, outputExtent: QgsRectangle, startTime: float, endTime: float, layer: QgsMeshLayer) Creates calculator with bounding box (rectangular) mask

Parameters
  • formulaString – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • outputDriver – output driver name

  • outputGroupName – output group name

  • outputFile – file to store the resulting dataset group data

  • outputExtent – spatial filter defined by rectangle

  • startTime – time filter defining the starting dataset

  • endTime – time filter defining the ending dataset

  • layer – mesh layer with dataset groups references in formulaString

New in version 3.12.

QgsMeshCalculator(formulaString: str, outputDriver: str, outputGroupName: str, outputFile: str, outputMask: QgsGeometry, startTime: float, endTime: float, layer: QgsMeshLayer) Creates calculator with geometry mask

Parameters
  • formulaString – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • outputDriver – output driver name

  • outputGroupName – output group name

  • outputFile – file to store the resulting dataset group data

  • outputMask – spatial filter defined by geometry

  • startTime – time filter defining the starting dataset

  • endTime – time filter defining the ending dataset

  • layer – mesh layer with dataset groups references in formulaString

New in version 3.12.

QgsMeshCalculator(formulaString: str, outputGroupName: str, outputExtent: QgsRectangle, destination: QgsMeshDatasetGroup.Type, layer: QgsMeshLayer, startTime: float, endTime: float) Creates calculator with bounding box (rectangular) mask, store the result in destination (must be on memory or virtual), see QgsMeshCalculator.Destination

Parameters
  • formulaString – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • outputGroupName – output group name

  • outputExtent – spatial filter defined by rectangle

  • destination – destination of the calculation (memory or virtual)

  • startTime – time filter defining the starting dataset

  • endTime – time filter defining the ending dataset

  • layer – mesh layer with dataset groups references in formulaString

New in version 3.16.

QgsMeshCalculator(formulaString: str, outputGroupName: str, outputMask: QgsGeometry, destination: QgsMeshDatasetGroup.Type, layer: QgsMeshLayer, startTime: float, endTime: float) Creates calculator with with geometry mask, store the result in destination (must be on memory or virtual), see QgsMeshCalculator.Destination

Parameters
  • formulaString – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • outputGroupName – output group name

  • outputMask – spatial filter defined by geometry

  • destination – destination of the calculation (memory or virtual)

  • startTime – time filter defining the starting dataset

  • endTime – time filter defining the ending dataset

  • layer – mesh layer with dataset groups references in formulaString

New in version 3.16.

QgsMeshCalculator(QgsMeshCalculator)

Performs mesh layer calculations.

Mesh calculator can do various mathematical operations between dataset groups from a single mesh layer. Resulting dataset group is added to the mesh layer. Result can be filtered by extent or a vector layer mask spatially and by selection of times.

Resulting dataset is always scalar

Methods

expressionIsValid

Returns whether formula is valid for particular mesh layer

expression_valid

Returns whether formula is valid for particular mesh layer

processCalculation

Starts the calculation, creates new dataset group and adds it to the mesh layer

Attributes

Canceled

CreateOutputError

EvaluateError

InputLayerError

InvalidDatasets

MemoryError

ParserError

Success

Canceled = 1
CreateOutputError = 2
EvaluateError = 6
InputLayerError = 3
InvalidDatasets = 5
MemoryError = 7
ParserError = 4
class Result

Bases: int

Success = 0
expressionIsValid(formulaString: str, layer: QgsMeshLayer) → Tuple[QgsMeshCalculator.Result, QgsMeshDriverMetadata.MeshDriverCapability]

Returns whether formula is valid for particular mesh layer

Parameters
  • formulaString (str) – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • layer (QgsMeshLayer) – mesh layer with dataset groups references in formulaString

  • requiredCapability – returns required capability of driver to store results of the calculation

Return type

Tuple[QgsMeshCalculator.Result, QgsMeshDriverMetadata.MeshDriverCapability]

Returns

QgsMeshCalculator.Success in case of success

New in version 3.12.

expression_valid(formulaString: str, layer: QgsMeshLayer)QgsMeshCalculator.Result

Returns whether formula is valid for particular mesh layer

Parameters
  • formulaString (str) – formula/expression to evaluate. Consists of dataset group names, operators and numbers

  • layer (QgsMeshLayer) – mesh layer with dataset groups references in formulaString

Return type

QgsMeshCalculator.Result

Returns

QgsMeshCalculator.Success in case of success

Deprecated since version QGIS: 3.12 - use expressionIsValid

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

Starts the calculation, creates new dataset group and adds it to the mesh layer

Parameters

feedback (QgsFeedback = None) – The optional feedback argument for progress reporting and cancellation support

Return type

QgsMeshCalculator.Result

Returns

QgsMeshCalculator.Success in case of success