Subgroup: Mesh

Class: QgsMeshLayer

class qgis.core.QgsMeshLayer(path: str = '', baseName: str = '', providerLib: str = '', options: QgsMeshLayer.LayerOptions = QgsMeshLayer.LayerOptions())

Bases: qgis._core.QgsMapLayer

Constructor - creates a mesh layer

The QgsMeshLayer is constructed by instantiating a data provider. The provider interprets the supplied path (url) of the data source to connect to and access the data.

Parameters:
  • path – The path or url of the parameter. Typically this encodes parameters used by the data provider as url query items.
  • baseName – The name used to represent the layer in the legend
  • providerLib – The name of the data provider, e.g., “mesh_memory”, “mdal”
  • options – general mesh layer options

Represents a mesh layer supporting display of data on structured or unstructured meshes

The QgsMeshLayer is instantiated by specifying the name of a data provider, such as mdal, and url defining the specific data set to connect to. The vector layer constructor in turn instantiates a QgsMeshDataProvider subclass corresponding to the provider type, and passes it the url. The data provider connects to the data source.

The QgsMeshLayer provides a common interface to the different data types. It does not yet support editing transactions.

The main data providers supported by QGIS are listed below.

section mesh_providers Mesh data providers

subsection mesh_memory Memory data providerType (mesh_memory)

The memory data provider is used to construct in memory data, for example scratch data. There is no inherent persistent storage of the data. The data source uri is constructed. Data can be populated by setMesh(const QString &vertices, const QString &faces), where vertices and faces is comma separated coordinates and connections for mesh. E.g. to create mesh with one quad and one triangle

subsection mdal MDAL data provider (mdal)

Accesses data using the MDAL drivers (https://github.com/lutraconsulting/MDAL). The url is the MDAL connection string. QGIS must be built with MDAL support to allow this provider.

Note

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

New in version 3.2: Methods

appendError
childEvent
clone
connectNotify
createMapRenderer
customEvent
dataProvider QgsMeshLayer cannot be copied.
datasetValue Interpolates the value on the given point from given dataset.
decodedSource
disconnectNotify
encodedSource
extent
hasDependencyCycle
isSignalConnected
providerType Returns the provider type for this layer
readCommonStyle
readCustomProperties
readStyleManager
readSymbology
readXml
receivers
rendererSettings Returns renderer settings
sender
senderSignalIndex
setError
setExtent
setRendererSettings Sets new renderer settings
setValid
timerEvent
writeCommonStyle
writeCustomProperties
writeStyleManager
writeSymbology
writeXml

Signals

activeScalarDatasetChanged Emitted when active scalar dataset is changed
activeVectorDatasetChanged Emitted when active vector dataset is changed

Attributes

class LayerOptions

Bases: sip.wrapper

QgsMeshLayer.LayerOptions(QgsMeshLayer.LayerOptions)

unused
activeScalarDatasetChanged

Emitted when active scalar dataset is changed

New in version 3.4: [signal]

activeVectorDatasetChanged

Emitted when active vector dataset is changed

New in version 3.4: [signal]

appendError()
childEvent()
clone(self) → QgsMeshLayer
connectNotify()
createMapRenderer(self, rendererContext: QgsRenderContext) → QgsMapLayerRenderer
customEvent()
dataProvider(self) → QgsMeshDataProvider

QgsMeshLayer cannot be copied.

datasetValue(self, index: QgsMeshDatasetIndex, point: QgsPointXY) → QgsMeshDatasetValue

Interpolates the value on the given point from given dataset.

Note

It uses previously cached and indexed triangular mesh and so if the layer has not been rendered previously (e.g. when used in a script) it returns NaN value

Parameters:
  • index – dataset index specifying group and dataset to extract value from
  • point – point to query in map coordinates
Returns:

interpolated value at the point. Returns NaN values for values outside the mesh layer, nodata values and in case triangular mesh was not previously used for rendering

New in version 3.4.

decodedSource(self, source: str, provider: str, context: QgsReadWriteContext) → str
disconnectNotify()
encodedSource(self, source: str, context: QgsReadWriteContext) → str
extent(self) → QgsRectangle
hasDependencyCycle()
isSignalConnected()
providerType(self) → str

Returns the provider type for this layer

readCommonStyle()
readCustomProperties()
readStyleManager()
readSymbology(self, node: QDomNode, errorMessage: str, context: QgsReadWriteContext) → bool
readXml(self, layer_node: QDomNode, context: QgsReadWriteContext) → bool
receivers()
rendererSettings(self) → QgsMeshRendererSettings

Returns renderer settings

sender()
senderSignalIndex()
setError()
setExtent()
setRendererSettings(self, settings: QgsMeshRendererSettings)

Sets new renderer settings

setValid()
timerEvent()
writeCommonStyle()
writeCustomProperties()
writeStyleManager()
writeSymbology(self, node: QDomNode, doc: QDomDocument, errorMessage: str, context: QgsReadWriteContext) → bool
writeXml(self, layer_node: QDomNode, doc: QDomDocument, context: QgsReadWriteContext) → bool