Class: QgsSpatialIndexKDBush¶
-
class
qgis.core.
QgsSpatialIndexKDBush
(fi: QgsFeatureIterator, feedback: QgsFeedback = None)¶ Bases:
sip.wrapper
Constructor - creates KDBush index and bulk loads it with features from the iterator.
The optional
feedback
object can be used to allow cancellation of bulk feature loading. Ownership offeedback
is not transferred, and callers must take care that the lifetime of feedback exceeds that of the spatial index construction.Any non-single point features encountered during iteration will be ignored and not included in the index.
QgsSpatialIndexKDBush(source:
QgsFeatureSource
, feedback:QgsFeedback
= None) Constructor - creates KDBush index and bulk loads it with features from the source.The optional
feedback
object can be used to allow cancellation of bulk feature loading. Ownership offeedback
is not transferred, and callers must take care that the lifetime of feedback exceeds that of the spatial index construction.Any non-single point features encountered during iteration will be ignored and not included in the index.
QgsSpatialIndexKDBush(other:
QgsSpatialIndexKDBush
) Copy constructorA very fast static spatial index for 2D points based on a flat KD-tree.
Compared to
QgsSpatialIndex
, this index: - supports single point features only (no multipoints) - is static (features cannot be added or removed from the index after construction) - is much faster! - allows direct retrieval of the original feature’s points, without requiring additional feature requests - supports true “distance based” searches, i.e. return all points within a radius from a search pointQgsSpatialIndexKDBush
objects are implicitly shared and can be inexpensively copied.See also
New in version 3.4.
- Parameters
fi (QgsFeatureIterator) –
feedback –
-
intersects
(self, rectangle: QgsRectangle) → object¶ Returns the list of features which fall within the specified
rectangle
.- Parameters
rectangle (QgsRectangle) –
- Return type
object
-
size
(self) → int¶ Returns the size of the index, i.e. the number of points contained within the index.
- Return type
int
-
within
(self, point: QgsPointXY, radius: float) → List[QgsSpatialIndexKDBushData]¶ Returns the list of features which are within the given search
radius
ofpoint
.- Parameters
point (QgsPointXY) –
radius (float) –
- Return type