Class: QgsMeshSpatialIndex

class qgis.core.QgsMeshSpatialIndex

Bases: sip.wrapper

Constructor for QgsSpatialIndex. Creates an empty R-tree index.

QgsMeshSpatialIndex(triangularMesh: QgsMesh, feedback: QgsFeedback = None) Constructor - creates R-tree and bulk loads faces from the specified mesh

The optional feedback object can be used to allow cancelation of bulk face loading. Ownership of feedback is not transferred, and callers must take care that the lifetime of feedback exceeds that of the spatial index construction.

QgsMeshSpatialIndex(other: QgsMeshSpatialIndex) Copy constructor

A spatial index for QgsMeshFace objects.

QgsMeshSpatialIndex objects are implicitly shared and can be inexpensively copied.

Note

While the underlying libspatialindex is not thread safe on some platforms, the QgsMeshSpatialIndex class implements its own locks and accordingly, a single QgsMeshSpatialIndex object can safely be used across multiple threads

See also

QgsSpatialIndex

New in version 3.6: Methods

intersects Returns a list of face ids with a bounding box which intersects the specified rectangle.
nearestNeighbor Returns nearest neighbors to a point.

Signals

Attributes

intersects(self, rectangle: QgsRectangle) → List[int]

Returns a list of face ids with a bounding box which intersects the specified rectangle.

Note

The intersection test is performed based on the face bounding boxes only, so it is necessary to manually test the returned faces for exact geometry intersection when required.

nearestNeighbor(self, point: QgsPointXY, neighbors: int) → List[int]

Returns nearest neighbors to a point. The number of neighbours returned is specified by the neighbours argument.

Note

The nearest neighbour test is performed based on the face bounding boxes only, so this method is not guaranteed to return the actual closest neighbours.