I built a manual index on a shapefile, through the process "Create spatial
index", which can be found in the process toolbox > general vector tools. This
process creates a persistent spatial index, a .quix file.
I want to optimize spatial queries on layers that have more than 300,000 records
Creating the spatial index with PyQGIS takes a little more than 6 seconds, as
you can see in the code
pry=QgsProject.instance()parcelas=pry.mapLayersByName('parcelas')[0]radios=pry.mapLayersByName('radios_censales')[0]
tiempo_inicial = time.time()index = QgsSpatialIndex() # Spatial indexindex =
QgsSpatialIndex(parcelas.getFeatures())duracionSI=time.time()-tiempo_inicial #
6.816403388977051 sec
But what I really want to do use leverage the existing .qix file directly, How
can I do this from PyQGIS?
Note: I am aware that the spatial index file must be updated if geometries are
modified, removed or added.
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer