Class: QgsMeshDatasetSourceInterface

Interface for mesh datasets and dataset groups.

Dataset is a collection of vector or scalar values on vertices or faces of the mesh. Based on the underlying data provider/format, whole dataset is either stored in memory or read on demand

Datasets are grouped in the dataset groups. A dataset group represents a measured quantity (e.g. depth or wind speed), dataset represents values of the quantity in a particular time.

Note

The API is considered EXPERIMENTAL and can be changed without a notice

Added in version 3.2.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: addDataset(), areFacesActive(), dataset3dValues(), datasetCount(), datasetGroupCount(), datasetGroupMetadata(), datasetMetadata(), datasetValue(), datasetValues(), extraDatasets(), isFaceActive(), persistDatasetGroup()

Class Hierarchy

Inheritance diagram of qgis.core.QgsMeshDatasetSourceInterface

Subclasses

QgsMeshDataProvider

Base class for providing data for QgsMeshLayer.

Abstract Methods

addDataset

Associate dataset with the mesh

areFacesActive

Returns whether the faces are active for particular dataset

dataset3dValues

Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes

datasetCount

Returns number of datasets loaded in the group

datasetGroupCount

Returns number of datasets groups loaded

datasetGroupMetadata

Returns dataset group metadata

datasetMetadata

Returns dataset metadata

datasetValue

Returns vector/scalar value associated with the index from the dataset To read multiple continuous values, use datasetValues()

datasetValues

Returns N vector/scalar values from the index from the dataset

extraDatasets

Returns list of additional dataset file URIs added using addDataset() calls.

isFaceActive

Returns whether the face is active for particular dataset

persistDatasetGroup

Creates a new dataset group from a data and persists it into a destination path

Methods

datasetIndexAtTime

Returns the dataset index of the dataset in a specific dataset group at time from the reference time

datasetIndexInTimeInterval

Returns a list of dataset indexes of the dataset in a specific dataset group that are between time1 and time2 from the reference time

class qgis.core.QgsMeshDatasetSourceInterface[source]

Bases: object

abstract addDataset(self, uri: str | None) bool[source]

Associate dataset with the mesh

emits dataChanged when successful

Parameters:

uri (Optional[str])

Return type:

bool

abstract areFacesActive(self, index: QgsMeshDatasetIndex, faceIndex: int, count: int) QgsMeshDataBlock[source]

Returns whether the faces are active for particular dataset

Added in version 3.6.

Parameters:
Return type:

QgsMeshDataBlock

abstract dataset3dValues(self, index: QgsMeshDatasetIndex, faceIndex: int, count: int) QgsMesh3DDataBlock[source]

Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes

See QgsMeshDatasetMetadata.isVector() to check if the returned value is vector or scalar

returns invalid block for DataOnFaces and DataOnVertices.

See also

datasetValues()

Added in version 3.12.

Parameters:
Return type:

QgsMesh3DDataBlock

abstract datasetCount(self, groupIndex: int) int[source]

Returns number of datasets loaded in the group

Parameters:

groupIndex (int)

Return type:

int

abstract datasetCount(self, index: QgsMeshDatasetIndex) int[source]

Returns number of datasets loaded in the group

Parameters:

index (QgsMeshDatasetIndex)

Return type:

int

abstract datasetGroupCount(self) int[source]

Returns number of datasets groups loaded

Return type:

int

abstract datasetGroupMetadata(self, groupIndex: int) QgsMeshDatasetGroupMetadata[source]

Returns dataset group metadata

Parameters:

groupIndex (int)

Return type:

QgsMeshDatasetGroupMetadata

abstract datasetGroupMetadata(self, index: QgsMeshDatasetIndex) QgsMeshDatasetGroupMetadata[source]

Returns dataset group metadata

Parameters:

index (QgsMeshDatasetIndex)

Return type:

QgsMeshDatasetGroupMetadata

datasetIndexAtTime(self, referenceTime: QDateTime | datetime.datetime, groupIndex: int, time: int, method: QgsMeshDataProviderTemporalCapabilities.MatchingTemporalDatasetMethod) QgsMeshDatasetIndex[source]

Returns the dataset index of the dataset in a specific dataset group at time from the reference time

Parameters:
Return type:

QgsMeshDatasetIndex

Returns:

the dataset index

datasetIndexInTimeInterval(self, referenceTime: QDateTime | datetime.datetime, groupIndex: int, time1: int, time2: int) List[QgsMeshDatasetIndex]

Returns a list of dataset indexes of the dataset in a specific dataset group that are between time1 and time2 from the reference time

Parameters:
  • referenceTime (Union[QDateTime, datetime.datetime]) – the reference time from where to find the dataset

  • groupIndex (int) – the index of the dataset group

  • time1 (int) – the first relative time of the time intervale from reference time

  • time2 (int) – the second relative time of the time intervale from reference time

Return type:

List[QgsMeshDatasetIndex]

Returns:

the dataset index

Added in version 3.22.

abstract datasetMetadata(self, index: QgsMeshDatasetIndex) QgsMeshDatasetMetadata[source]

Returns dataset metadata

Parameters:

index (QgsMeshDatasetIndex)

Return type:

QgsMeshDatasetMetadata

abstract datasetValue(self, index: QgsMeshDatasetIndex, valueIndex: int) QgsMeshDatasetValue[source]

Returns vector/scalar value associated with the index from the dataset To read multiple continuous values, use datasetValues()

See QgsMeshDatasetMetadata.isVector() or QgsMeshDataBlock.type() to check if the returned value is vector or scalar

Returns invalid value for DataOnVolumes

See also

datasetValues()

Parameters:
Return type:

QgsMeshDatasetValue

abstract datasetValues(self, index: QgsMeshDatasetIndex, valueIndex: int, count: int) QgsMeshDataBlock[source]

Returns N vector/scalar values from the index from the dataset

See QgsMeshDatasetMetadata.isVector() or QgsMeshDataBlock.type() to check if the returned value is vector or scalar

Returns invalid block for DataOnVolumes. Use QgsMeshLayerUtils.datasetValues() if you need block for any type of data type

Added in version 3.6.

Parameters:
Return type:

QgsMeshDataBlock

abstract extraDatasets(self) List[str][source]

Returns list of additional dataset file URIs added using addDataset() calls.

Return type:

List[str]

abstract isFaceActive(self, index: QgsMeshDatasetIndex, faceIndex: int) bool[source]

Returns whether the face is active for particular dataset

For example to represent the situation when F1 and F3 are flooded, but F2 is dry, some solvers store water depth on vertices V1-V8 (all non-zero values) and set active flag for F2 to False. V1 —- V2 —- V5—–V7 | F1 | F2 | F3 | V3 —- V4 —- V6—–V8

Parameters:
Return type:

bool

abstract persistDatasetGroup(self, path: str | None, meta: QgsMeshDatasetGroupMetadata, datasetValues: Iterable[QgsMeshDataBlock], datasetActive: Iterable[QgsMeshDataBlock], times: Iterable[float]) bool[source]

Creates a new dataset group from a data and persists it into a destination path

On success, the mesh’s dataset group count is changed

Parameters:
  • path (Optional[str]) – destination path of the stored file in form DRIVER_NAME:path

  • meta (QgsMeshDatasetGroupMetadata) – new group’s metadata

  • datasetValues (Iterable[QgsMeshDataBlock]) – scalar/vector values for all datasets and all faces/vertices in the group

  • datasetActive (Iterable[QgsMeshDataBlock]) – active flag values for all datasets in the group. Empty array represents can be used when all faces are active

  • times (Iterable[float]) – times in hours for all datasets in the group

Return type:

bool

Returns:

True on failure, False on success

Note

Doesn’t work if there is “:” in the path (e.g. Windows system)

Added in version 3.6.

Deprecated since version 3.12.3.

abstract persistDatasetGroup(self, outputFilePath: str | None, outputDriver: str | None, meta: QgsMeshDatasetGroupMetadata, datasetValues: Iterable[QgsMeshDataBlock], datasetActive: Iterable[QgsMeshDataBlock], times: Iterable[float]) bool[source]

Creates a new dataset group from a data and persists it into a destination path

On success, the mesh’s dataset group count is changed

Parameters:
  • outputFilePath (Optional[str]) – destination path of the stored file

  • outputDriver (Optional[str]) – output driver name

  • meta (QgsMeshDatasetGroupMetadata) – new group’s metadata

  • datasetValues (Iterable[QgsMeshDataBlock]) – scalar/vector values for all datasets and all faces/vertices in the group

  • datasetActive (Iterable[QgsMeshDataBlock]) – active flag values for all datasets in the group. Empty array represents can be used when all faces are active

  • times (Iterable[float]) – times in hours for all datasets in the group

Return type:

bool

Returns:

True on failure, False on success

Added in version 3.12.3.

abstract persistDatasetGroup(self, outputFilePath: str | None, outputDriver: str | None, source: QgsMeshDatasetSourceInterface | None, datasetGroupIndex: int) bool[source]

Saves a an existing dataset group provided by source to a file with a specified driver

On success, the mesh’s dataset group count is changed

Parameters:
  • outputFilePath (Optional[str]) – destination path of the stored file

  • outputDriver (Optional[str]) – output driver name

  • source (Optional[QgsMeshDatasetSourceInterface]) – source of the dataset group

  • datasetGroupIndex (int) – index of the dataset group in the source

Return type:

bool

Returns:

True on failure, False on success

Added in version 3.16.