Class: QgsMeshLayer¶
- class qgis.core.QgsMeshLayer¶
Bases:
QgsMapLayer
,QgsAbstractProfileSource
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 aQgsMeshDataProvider
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.
Mesh data providers¶
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
uri = "1.0, 2.0 \n" \ "2.0, 2.0 \n" \ "3.0, 2.0 \n" \ "2.0, 3.0 \n" \ "1.0, 3.0 \n" \ "---" \ "0, 1, 3, 4 \n" \ "1, 2, 3 \n" scratchLayer = QgsMeshLayer(uri, "My Scratch layer", "mesh_memory")
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.
uri = "test/land.2dm" scratchLayer = QgsMeshLayer(uri, "My Scratch Layer", "mdal")
Note
The API is considered EXPERIMENTAL and can be changed without a notice
New in version 3.2.
QgsMeshLayer(path: str = ‘’, baseName: str = ‘’, providerLib: str = ‘’, options: QgsMeshLayer.LayerOptions = QgsMeshLayer.LayerOptions()) 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.- param path:
The path or url of the parameter. Typically this encodes parameters used by the data provider as url query items.
- param baseName:
The name used to represent the layer in the legend
- param providerLib:
The name of the data provider, e.g., “mesh_memory”, “mdal”
- param options:
general mesh layer options
Methods
Returns dataset index from active scalar group depending on the time range.
Returns dataset index from active vector group depending on the time range If the temporal properties is not active, return the static dataset
Adds datasets to the mesh from file with
path
.Add error message
Returns whether the faces are active for particular dataset
- rtype:
QgsMeshLayer
Commits editing of the mesh frame, Rebuilds the triangular mesh and its spatial index with
transform
, Continue editing with the same mesh editor ifcontinueEditing
is TrueReturns whether the mesh contains at mesh elements of given type
- param rendererContext:
- param request:
- rtype:
QgsMeshDataProvider
Returns the value of 1D mesh dataset defined on edge that are in the search area defined by point ans searchRadius
Returns the 3d values of stacked 3d mesh defined by the given point
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes
Returns the dataset count in the dataset groups
Returns the dataset groups count handle by the layer
Returns the dataset groups metadata
Returns the root items of the dataset group tree item
Returns the list of indexes of dataset groups handled by the layer
Returns dataset index from datasets group depending on the relative time from the layer reference time.
Returns dataset index from datasets group depending on the time range.
Returns a list of dataset indexes from datasets group that are in a interval time from the layer reference time.
Returns the dataset metadata
Returns the relative time of the dataset from the reference time of its group
Returns the relative time (in milliseconds) of the dataset from the reference time of its group
Returns vector/scalar value associated with the index from the dataset To read multiple continuous values, use
datasetValues()
Returns N vector/scalar values from the index from the dataset
- param source:
- rtype:
QgsMapLayerElevationProperties
Returns the list of indexes of enables dataset groups handled by the layer
- param source:
- rtype:
QgsRectangle
Returns the extra dataset groups count handle by the layer
Returns the first valid time step of the dataset groups, invalid QgInterval if no time step is present
Returns (date) time in hours formatted to human readable form
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and always return
False
, because circular dependencies are now correctly managed.- rtype:
str
Invalidates the WGS84 extent.
- rtype:
bool
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes
Returns whether the mesh frame has been modified since the last save
Access to labeling configuration.
Returns whether the layer contains labels which are enabled and should be drawn.
- rtype:
Tuple[str, bool]
Returns the edges count of the mesh frame
Returns a pointer to the mesh editor own by the mesh layer
Returns the faces count of the mesh frame
Returns the vertices count of the mesh frame
Returns the provider type for this layer
Read style data common to all layer types
Read custom properties from project file.
- param node:
Read style manager's configuration (if any).
- param node:
- param layer_node:
Re-indexes the faces and vertices, and renumber the indexes if
renumber
isTrue
.Returns renderer settings
Reset the dataset group tree item to default from provider
Rolls Back editing of the mesh frame.
Saves datasets group on file with the specified
driver
Returns a list of faces indexes that meet the condition defined by
expression
with the contextexpressionContext
Returns a list of vertex indexes that meet the condition defined by
expression
with the contextexpressionContext
Sets the root items of the dataset group tree item.
Sets error message
Sets the extent
Sets the extent
Sets labeling configuration.
Sets whether labels should be
enabled
for the layer.Sets the
providerType
(provider key)Sets the reference time of the layer
Sets new renderer settings
Sets the method used to match the temporal dataset from a requested time, see
activeVectorDatasetAtTime()
Sets time format settings
Sets the coordinate transform context to
transformContext
.Sets whether layer is valid or not
Returns the position of the snapped point on the mesh element closest to
point
intersecting with the searching area defined bypoint
andsearchRadius
Starts editing of the mesh frame.
Returns the static scalar dataset index that is rendered if the temporal properties is not active
Returns the static vector dataset index that is rendered if the temporal properties is not active
Stops editing of the mesh, re-indexes the faces and vertices, rebuilds the triangular mesh and its spatial index with
transform
, clean the undostack- rtype:
List[str]
- rtype:
bool
- rtype:
QgsMapLayerTemporalProperties
Returns time format settings
Gets native mesh and updates (creates if it doesn't exist) the base triangular mesh
Write style data common to all layer types
Write custom properties to project file.
- param node:
Write style manager's configuration (if exists).
- param node:
- param layer_node:
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- class LayerOptions(transformContext: QgsCoordinateTransformContext = QgsCoordinateTransformContext())¶
Bases:
sip.wrapper
Constructor for LayerOptions with optional
transformContext
.Note
transformContext argument was added in QGIS 3.8
QgsMeshLayer.LayerOptions(QgsMeshLayer.LayerOptions)
- loadDefaultStyle¶
- skipCrsValidation¶
- transformContext¶
- activeScalarDatasetAtTime(self, timeRange: QgsDateTimeRange) QgsMeshDatasetIndex ¶
Returns dataset index from active scalar group depending on the time range. If the temporal properties is not active, return the static dataset
- Parameters:
timeRange (QgsDateTimeRange) – the time range
- Return type:
- Returns:
dataset index
Note
the returned dataset index depends on the matching method, see
setTemporalMatchingMethod()
New in version 3.14.
- activeScalarDatasetGroupChanged¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- activeVectorDatasetAtTime(self, timeRange: QgsDateTimeRange) QgsMeshDatasetIndex ¶
Returns dataset index from active vector group depending on the time range If the temporal properties is not active, return the static dataset
- Parameters:
timeRange (QgsDateTimeRange) – the time range
- Return type:
- Returns:
dataset index
Note
the returned dataset index depends on the matching method, see
setTemporalMatchingMethod()
New in version 3.14.
- activeVectorDatasetGroupChanged¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- addDatasets(self, path: str, defaultReferenceTime: QDateTime | datetime.datetime = QDateTime()) bool ¶
Adds datasets to the mesh from file with
path
. Use the the timedefaultReferenceTime
as reference time is not provided in the file- Parameters:
path (str) – the path to the atasets file
defaultReferenceTime (Union[QDateTime) – reference time used if not provided in the file
- Returns:
whether the dataset is added
New in version 3.14.
addDatasets(self, datasetGroup:
QgsMeshDatasetGroup
) -> bool Adds extra datasets to the mesh. Take ownership.- Parameters:
datasetGroup – the extra dataset group
- Return type:
bool
- Returns:
whether the dataset is effectively added
New in version 3.16.
- appendError(self, error: QgsErrorMessage)¶
Add error message
- areFacesActive(self, index: QgsMeshDatasetIndex, faceIndex: int, count: int) QgsMeshDataBlock ¶
Returns whether the faces are active for particular dataset
- Parameters:
index (QgsMeshDatasetIndex) – index of the dataset
faceIndex (int) – index of the face
count (int) – number of values to return
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes are different from the data provider indexes.
New in version 3.16.
- Return type:
- childEvent(self, QChildEvent)¶
- clone(self) QgsMeshLayer ¶
- Return type:
- commitFrameEditing(self, transform: QgsCoordinateTransform, continueEditing: bool = True) bool ¶
Commits editing of the mesh frame, Rebuilds the triangular mesh and its spatial index with
transform
, Continue editing with the same mesh editor ifcontinueEditing
is True- Return type:
bool
- Returns:
True
if the commit succeeds
New in version 3.22.
- Parameters:
transform (QgsCoordinateTransform) –
continueEditing (bool = True) –
- connectNotify(self, QMetaMethod)¶
- contains(self, type: QgsMesh.ElementType) bool ¶
Returns whether the mesh contains at mesh elements of given type
New in version 3.22.
- Parameters:
type (QgsMesh.ElementType) –
- Return type:
bool
- createMapRenderer(self, rendererContext: QgsRenderContext) QgsMapLayerRenderer ¶
- Parameters:
rendererContext (QgsRenderContext) –
- Return type:
- createProfileGenerator(self, request: QgsProfileRequest) QgsAbstractProfileGenerator ¶
- Parameters:
request (QgsProfileRequest) –
- Return type:
- customEvent(self, QEvent)¶
- dataProvider(self) QgsMeshDataProvider ¶
- Return type:
- dataset1dValue(self, index: QgsMeshDatasetIndex, point: QgsPointXY, searchRadius: float) QgsMeshDatasetValue ¶
Returns the value of 1D mesh dataset defined on edge that are in the search area defined by point ans searchRadius
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
See also
- Parameters:
index (QgsMeshDatasetIndex) – dataset index specifying group and dataset to extract value from
point (QgsPointXY) – the center point of the search area
searchRadius (float) – the radius of the searc area in map unit
- Return type:
- Returns:
interpolated value at the projected point. Returns NaN values for values outside the mesh layer and in case triangular mesh was not previously used for rendering
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes are different from the data provider indexes.
New in version 3.14.
- dataset3dValue(self, index: QgsMeshDatasetIndex, point: QgsPointXY) QgsMesh3DDataBlock ¶
Returns the 3d values of stacked 3d mesh defined by the given point
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
See also
- Parameters:
index (QgsMeshDatasetIndex) – dataset index specifying group and dataset to extract value from
point (QgsPointXY) – point to query in map coordinates
- Return type:
- Returns:
all 3d stacked values that belong to face defined by given point. Returns invalid block for point outside the mesh layer or in case triangular mesh was not previously used for rendering or for datasets that do not have type DataOnVolumes
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes are different from the data provider indexes.
New in version 3.12.
- dataset3dValues(self, index: QgsMeshDatasetIndex, faceIndex: int, count: int) QgsMesh3DDataBlock ¶
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 scalarreturns invalid block for DataOnFaces and DataOnVertices.
- Parameters:
index (QgsMeshDatasetIndex) – index of the dataset
faceIndex (int) – index of the face
count (int) – number of values to return
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.
- Return type:
- datasetCount(self, index: QgsMeshDatasetIndex) int ¶
Returns the dataset count in the dataset groups
- Parameters:
index (QgsMeshDatasetIndex) – index of the dataset in the group
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.
- Return type:
int
- datasetGroupCount(self) int ¶
Returns the dataset groups count handle by the layer
New in version 3.16.
- Return type:
int
- datasetGroupMetadata(self, index: QgsMeshDatasetIndex) QgsMeshDatasetGroupMetadata ¶
Returns the dataset groups metadata
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.
- Parameters:
index (QgsMeshDatasetIndex) –
- Return type:
- datasetGroupTreeRootItem(self) QgsMeshDatasetGroupTreeItem ¶
Returns the root items of the dataset group tree item
- Return type:
- Returns:
the root item
New in version 3.14.
- datasetGroupsIndexes(self) List[int] ¶
Returns the list of indexes of dataset groups handled by the layer
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.
- Return type:
List[int]
- datasetIndexAtRelativeTime(self, relativeTime: QgsInterval, datasetGroupIndex: int) QgsMeshDatasetIndex ¶
Returns dataset index from datasets group depending on the relative time from the layer reference time. Dataset index is valid even the temporal properties is inactive. This method is used for calculation on mesh layer.
- Parameters:
relativeTime (QgsInterval) – the relative from the mesh layer reference time
datasetGroupIndex (int) – the index of the dataset group
- Return type:
- Returns:
dataset index
Note
the returned dataset index depends on the matching method, see
setTemporalMatchingMethod()
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes are different from the data provider indexes.
New in version 3.16.
- datasetIndexAtTime(self, timeRange: QgsDateTimeRange, datasetGroupIndex: int) QgsMeshDatasetIndex ¶
Returns dataset index from datasets group depending on the time range. If the temporal properties is not active, returns invalid dataset index. This method is used for rendering mesh layer.
- Parameters:
timeRange (QgsDateTimeRange) – the time range
datasetGroupIndex (int) – the index of the dataset group
- Return type:
- Returns:
dataset index
Note
the returned dataset index depends on the matching method, see
setTemporalMatchingMethod()
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes are different from the data provider indexes.
New in version 3.14.
- datasetIndexInRelativeTimeInterval(self, startRelativeTime: QgsInterval, endRelativeTime: QgsInterval, datasetGroupIndex: int) List[QgsMeshDatasetIndex] ¶
Returns a list of dataset indexes from datasets group that are in a interval time from the layer reference time. Dataset index is valid even the temporal properties is inactive. This method is used for calculation on mesh layer.
- Parameters:
startRelativeTime (QgsInterval) – the start time of the relative interval from the reference time.
endRelativeTime (QgsInterval) – the end time of the relative interval from the reference time.
datasetGroupIndex (int) – the index of the dataset group
- Return type:
List[QgsMeshDatasetIndex]
- Returns:
dataset index
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes are different from the data provider indexes.
New in version 3.22.
- datasetMetadata(self, index: QgsMeshDatasetIndex) QgsMeshDatasetMetadata ¶
Returns the dataset metadata
- Parameters:
index (QgsMeshDatasetIndex) – index of the dataset
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.
- Return type:
- datasetRelativeTime(self, index: QgsMeshDatasetIndex) QgsInterval ¶
Returns the relative time of the dataset from the reference time of its group
New in version 3.16.
- Parameters:
index (QgsMeshDatasetIndex) –
- Return type:
- datasetRelativeTimeInMilliseconds(self, index: QgsMeshDatasetIndex) int ¶
Returns the relative time (in milliseconds) of the dataset from the reference time of its group
New in version 3.16.
- Parameters:
index (QgsMeshDatasetIndex) –
- Return type:
int
- datasetValue(self, index: QgsMeshDatasetIndex, valueIndex: int) QgsMeshDatasetValue ¶
Returns vector/scalar value associated with the index from the dataset To read multiple continuous values, use
datasetValues()
See
QgsMeshDatasetMetadata.isVector()
orQgsMeshDataBlock.type()
to check if the returned value is vector or scalarReturns invalid value for DataOnVolumes
- Parameters:
index (QgsMeshDatasetIndex) – index of the dataset
valueIndex (int) – index of the value
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.
datasetValue(self, index:
QgsMeshDatasetIndex
, point:QgsPointXY
, searchRadius: float = 0) -> QgsMeshDatasetValue Interpolates the value on the given point from given dataset. For 3D datasets, it usesdataset3dValue()
, n For 1D datasets, it usesdataset1dValue()
withsearchRadius
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
See also
- Parameters:
index – dataset index specifying group and dataset to extract value from
point – point to query in map coordinates
searchRadius – the radius of the search area in map unit
- Return type:
- 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
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes are different from the data provider indexes.
New in version 3.4.
- datasetValues(self, index: QgsMeshDatasetIndex, valueIndex: int, count: int) QgsMeshDataBlock ¶
Returns N vector/scalar values from the index from the dataset
See
QgsMeshDatasetMetadata.isVector()
orQgsMeshDataBlock.type()
to check if the returned value is vector or scalarReturns invalid block for DataOnVolumes. Use
QgsMeshLayerUtils.datasetValues()
if you need block for any type of data type- Parameters:
index (QgsMeshDatasetIndex) – index of the dataset
valueIndex (int) – index of the value
count (int) – number of values to return
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.
- Return type:
- decodedSource(self, source: str, provider: str, context: QgsReadWriteContext) str ¶
- Parameters:
source (str) –
provider (str) –
context (QgsReadWriteContext) –
- Return type:
str
- disconnectNotify(self, QMetaMethod)¶
- elevationProperties(self) QgsMapLayerElevationProperties ¶
- Return type:
- enabledDatasetGroupsIndexes(self) List[int] ¶
Returns the list of indexes of enables dataset groups handled by the layer
Note
indexes are used to distinguish all the dataset groups handled by the layer (from dataprovider, extra dataset group,…) In the layer scope, those indexes can be different from the data provider indexes.
New in version 3.16.3.
- Return type:
List[int]
- encodedSource(self, source: str, context: QgsReadWriteContext) str ¶
- Parameters:
source (str) –
context (QgsReadWriteContext) –
- Return type:
str
- extent(self) QgsRectangle ¶
- Return type:
- extraDatasetGroupCount(self) int ¶
Returns the extra dataset groups count handle by the layer
New in version 3.16.
- Return type:
int
- firstValidTimeStep(self) QgsInterval ¶
Returns the first valid time step of the dataset groups, invalid QgInterval if no time step is present
New in version 3.14.
- Return type:
- formatTime(self, hours: float) str ¶
Returns (date) time in hours formatted to human readable form
- Parameters:
hours (float) – time in double in hours
- Return type:
str
- Returns:
formatted time string
New in version 3.8.
- hasDependencyCycle(self, Iterable[QgsMapLayerDependency]) bool ¶
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and always return
False
, because circular dependencies are now correctly managed.Deprecated since version QGIS: 3.10
- htmlMetadata(self) str ¶
- Return type:
str
- invalidateWgs84Extent(self)¶
Invalidates the WGS84 extent. If FlagTrustLayerMetadata is enabled, the extent is not invalidated because we want to trust metadata whatever happens.
New in version 3.20.
- isEditable(self) bool ¶
- Return type:
bool
- isFaceActive(self, index: QgsMeshDatasetIndex, faceIndex: int) bool ¶
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 scalarreturns invalid block for DataOnFaces and DataOnVertices.
- Parameters:
index (QgsMeshDatasetIndex) –
faceIndex (int) –
- Return type:
bool
- isModified(self) bool ¶
Returns whether the mesh frame has been modified since the last save
New in version 3.22.
- Return type:
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- labeling(self) QgsAbstractMeshLayerLabeling ¶
Access to labeling configuration. May be
None
if labeling is not used.Note
Labels will only be rendered if
labelsEnabled()
returnsTrue
.See also
New in version 3.36.
- Return type:
- labelsEnabled(self) bool ¶
Returns whether the layer contains labels which are enabled and should be drawn.
- Return type:
bool
- Returns:
True
if layer contains enabled labels
See also
See also
New in version 3.36.
- loadDefaultStyle(self) Tuple[str, bool] ¶
- Return type:
Tuple[str, bool]
- meshEdgeCount(self) int ¶
Returns the edges count of the mesh frame
New in version 3.22.
- Return type:
int
- meshEditor(self) QgsMeshEditor ¶
Returns a pointer to the mesh editor own by the mesh layer
New in version 3.22.
- Return type:
- meshFaceCount(self) int ¶
Returns the faces count of the mesh frame
Note
during mesh editing, some faces can be void and are not included in this returned value
New in version 3.22.
- Return type:
int
- meshVertexCount(self) int ¶
Returns the vertices count of the mesh frame
Note
during mesh editing, some vertices can be void and are not included in this returned value
New in version 3.22.
- Return type:
int
- providerType(self) str ¶
Returns the provider type for this layer
- Return type:
str
- readCommonStyle(self, layerElement: QDomElement, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories)¶
Read style data common to all layer types
- readCustomProperties(self, layerNode: QDomNode, keyStartsWith: str = '')¶
Read custom properties from project file.
- Parameters:
layerNode – note to read from
keyStartsWith – reads only properties starting with the specified string (or all if the string is empty)
- readStyle(self, node: QDomNode, errorMessage: str, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool ¶
- Parameters:
node (QDomNode) –
errorMessage (str) –
context (QgsReadWriteContext) –
categories (Union[QgsMapLayer.StyleCategories) –
- Return type:
bool
- readStyleManager(self, layerNode: QDomNode)¶
Read style manager’s configuration (if any). To be called by subclasses.
- readSymbology(self, node: QDomNode, errorMessage: str, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool ¶
- Parameters:
node (QDomNode) –
errorMessage (str) –
context (QgsReadWriteContext) –
categories (Union[QgsMapLayer.StyleCategories) –
- Return type:
bool
- readXml(self, layer_node: QDomNode, context: QgsReadWriteContext) bool ¶
- Parameters:
layer_node (QDomNode) –
context (QgsReadWriteContext) –
- Return type:
bool
- receivers(self, PYQT_SIGNAL) int ¶
- reindex(self, transform: QgsCoordinateTransform, renumber: bool) bool ¶
Re-indexes the faces and vertices, and renumber the indexes if
renumber
isTrue
. rebuilds the triangular mesh and its spatial index withtransform
, clean the undostackReturns
False
if the operation failsNew in version 3.22.
- Parameters:
transform (QgsCoordinateTransform) –
renumber (bool) –
- Return type:
bool
- reload(self)¶
- reloaded¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- rendererSettings(self) QgsMeshRendererSettings ¶
Returns renderer settings
- Return type:
- resetDatasetGroupTreeItem(self)¶
Reset the dataset group tree item to default from provider
New in version 3.14.
- rollBackFrameEditing(self, transform: QgsCoordinateTransform, continueEditing: bool = True) bool ¶
Rolls Back editing of the mesh frame. Reload mesh from file, rebuilds the triangular mesh and its spatial index with
transform
, Continue editing with the same mesh editor ifcontinueEditing
isTrue
- Return type:
bool
- Returns:
True
if the rollback succeeds
New in version 3.22.
- Parameters:
transform (QgsCoordinateTransform) –
continueEditing (bool = True) –
- saveDataset(self, path: str, datasetGroupIndex: int, driver: str) bool ¶
Saves datasets group on file with the specified
driver
- Parameters:
path (str) – the path of the file
datasetGroupIndex (int) – the index of the dataset group
driver (str) – the driver to used for saving
- Return type:
bool
- Returns:
false if succeeds
New in version 3.16.
- selectFacesByExpression(self, expression: QgsExpression) List[int] ¶
Returns a list of faces indexes that meet the condition defined by
expression
with the contextexpressionContext
To express the relation with a face, the expression can be defined with function returning value linked to the current face, like “ $face_area “
New in version 3.22.
- Parameters:
expression (QgsExpression) –
- Return type:
List[int]
- selectVerticesByExpression(self, expression: QgsExpression) List[int] ¶
Returns a list of vertex indexes that meet the condition defined by
expression
with the contextexpressionContext
To express the relation with a vertex, the expression can be defined with function returning value linked to the current vertex, like “ $vertex_z “, “$vertex_as_point”
New in version 3.22.
- Parameters:
expression (QgsExpression) –
- Return type:
List[int]
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setDatasetGroupTreeRootItem(self, rootItem: QgsMeshDatasetGroupTreeItem)¶
Sets the root items of the dataset group tree item. Changes active dataset groups if those one are not enabled anymore :
new active scalar dataset group is the first root item enabled child
new active vector dataset group is none
Doesn’t take ownership of the pointed item, the root item is cloned.
- Parameters:
rootItem (QgsMeshDatasetGroupTreeItem) – the new root item
New in version 3.14.
- setExtent(self, rect: QgsRectangle)¶
Sets the extent
- setLabeling(self, labeling: QgsAbstractMeshLayerLabeling)¶
Sets labeling configuration. Takes ownership of the object.
New in version 3.36.
- Parameters:
labeling (QgsAbstractMeshLayerLabeling) –
- setLabelsEnabled(self, enabled: bool)¶
Sets whether labels should be
enabled
for the layer.Note
Labels will only be rendered if
labelsEnabled()
isTrue
and a labeling object is returned bylabeling()
.See also
See also
New in version 3.36.
- Parameters:
enabled (bool) –
- setProviderType(self, providerType: str)¶
Sets the
providerType
(provider key)
- setReferenceTime(self, referenceTime: QDateTime | datetime.datetime)¶
Sets the reference time of the layer
- Parameters:
referenceTime (Union[QDateTime) – the reference time
New in version 3.14.
- setRendererSettings(self, settings: QgsMeshRendererSettings)¶
Sets new renderer settings
- Parameters:
settings (QgsMeshRendererSettings) –
- setTemporalMatchingMethod(self, matchingMethod: QgsMeshDataProviderTemporalCapabilities.MatchingTemporalDatasetMethod)¶
Sets the method used to match the temporal dataset from a requested time, see
activeVectorDatasetAtTime()
- Parameters:
matchingMethod (QgsMeshDataProviderTemporalCapabilities.MatchingTemporalDatasetMethod) – the matching method
New in version 3.14.
- setTimeSettings(self, settings: QgsMeshTimeSettings)¶
Sets time format settings
New in version 3.8.
- Parameters:
settings (QgsMeshTimeSettings) –
- setTransformContext(self, transformContext: QgsCoordinateTransformContext)¶
Sets the coordinate transform context to
transformContext
.New in version 3.8.
- Parameters:
transformContext (QgsCoordinateTransformContext) –
- setValid(self, valid: bool)¶
Sets whether layer is valid or not
- snapOnElement(self, elementType: QgsMesh.ElementType, point: QgsPointXY, searchRadius: float) QgsPointXY ¶
Returns the position of the snapped point on the mesh element closest to
point
intersecting with the searching area defined bypoint
andsearchRadius
For vertex, the snapped position is the vertex position For edge, the snapped position is the projected point on the edge, extremity of edge if outside the edge For face, the snapped position is the centroid of the face The returned position is in map coordinates.
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 empty
QgsPointXY
See also
- Parameters:
elementType (QgsMesh.ElementType) – the type of element to snap
point (QgsPointXY) – the center of the search area in map coordinates
searchRadius (float) – the radius of the search area in map units
- Return type:
- Returns:
the position of the snapped point on the closest element, empty
QgsPointXY
if no element of typeelementType
New in version 3.14.
- startFrameEditing(self, transform: QgsCoordinateTransform) bool ¶
Starts editing of the mesh frame. Coordinate
transform
used to initialize the triangular mesh if needed. This operation will disconnect the mesh layer from the data provider and removes all existing dataset groupNew in version 3.22.
Deprecated since version QGIS: 3.28 use the version with
QgsMeshEditingError
insteadstartFrameEditing(self, transform:
QgsCoordinateTransform
, fixErrors: bool) -> Tuple[bool, QgsMeshEditingError] Starts editing of the mesh frame. Coordinatetransform
used to initialize the triangular mesh if needed. This operation will disconnect the mesh layer from the data provider and removes all existing dataset group. ReturnsFalse
if starting fails and theerror
that is the reason (No error, if the mesh is not editable or already in edit mode).If
fixErrors
is set toTrue
, errors will be attempted to be fixed. In that case returnsFalse
if there is an error that could not be fixed and the remainingerror
.New in version 3.28.
- Parameters:
transform (QgsCoordinateTransform) –
- Return type:
bool
- staticScalarDatasetIndex(self) QgsMeshDatasetIndex ¶
Returns the static scalar dataset index that is rendered if the temporal properties is not active
New in version 3.14.
- Return type:
- staticVectorDatasetIndex(self) QgsMeshDatasetIndex ¶
Returns the static vector dataset index that is rendered if the temporal properties is not active
New in version 3.14.
- Return type:
- stopFrameEditing(self, transform: QgsCoordinateTransform)¶
Stops editing of the mesh, re-indexes the faces and vertices, rebuilds the triangular mesh and its spatial index with
transform
, clean the undostackNew in version 3.22.
- Parameters:
transform (QgsCoordinateTransform) –
- subLayers(self) List[str] ¶
- Return type:
List[str]
- supportsEditing(self) bool ¶
- Return type:
bool
- temporalProperties(self) QgsMapLayerTemporalProperties ¶
- Return type:
- timeSettings(self) QgsMeshTimeSettings ¶
Returns time format settings
New in version 3.8.
- Return type:
- timeSettingsChanged¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- timerEvent(self, QTimerEvent)¶
- updateTriangularMesh(self, transform: QgsCoordinateTransform = QgsCoordinateTransform())¶
Gets native mesh and updates (creates if it doesn’t exist) the base triangular mesh
- Parameters:
transform (
QgsCoordinateTransform
= QgsCoordinateTransform()) – Transformation from layer CRS to destination (e.g. map) CRS. With invalid transform, it keeps the native mesh CRS
New in version 3.14.
- writeCommonStyle(self, layerElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories)¶
Write style data common to all layer types
- writeCustomProperties(self, layerNode: QDomNode, doc: QDomDocument)¶
Write custom properties to project file.
- writeStyle(self, node: QDomNode, doc: QDomDocument, errorMessage: str, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool ¶
- Parameters:
node (QDomNode) –
doc (QDomDocument) –
errorMessage (str) –
context (QgsReadWriteContext) –
categories (Union[QgsMapLayer.StyleCategories) –
- Return type:
bool
- writeStyleManager(self, layerNode: QDomNode, doc: QDomDocument)¶
Write style manager’s configuration (if exists). To be called by subclasses.
- writeSymbology(self, node: QDomNode, doc: QDomDocument, errorMessage: str, context: QgsReadWriteContext, categories: QgsMapLayer.StyleCategories | QgsMapLayer.StyleCategory = QgsMapLayer.AllStyleCategories) bool ¶
- Parameters:
node (QDomNode) –
doc (QDomDocument) –
errorMessage (str) –
context (QgsReadWriteContext) –
categories (Union[QgsMapLayer.StyleCategories) –
- Return type:
bool
- writeXml(self, layer_node: QDomNode, doc: QDomDocument, context: QgsReadWriteContext) bool ¶
- Parameters:
layer_node (QDomNode) –
doc (QDomDocument) –
context (QgsReadWriteContext) –
- Return type:
bool