registry = QgsProject.instance() first_layer = registry.mapLayersByName('buffered') second_layer = registry.mapLayersByName('buffered') areas =  instrument_number = "tin_ttl_in" proprietor = "tin_ttl_re" #input field name for the registered proprietor SLayerList = second_layer.getFeatures() for first_feature in SLayerList: tempLayer =first_layer.getFeatures(QgsFeatureRequest().setFilterRect(first_feature.geometry().boundingBox())) for second_feature in tempLayer: if first_feature.geometry().overlaps(second_feature.geometry()): if (first_feature[instrument_number] == second_feature[instrument_number]) or (first_feature[proprietor] == second_feature[proprietor]): areas.append(first_feature.id()) first_layer.select(areas)
I'm having trouble with this script running very slow and I believe it could be because I'm making too many calls to getFeatures() or having a nested for loop? But I am not hugely experienced in Python or pyqgis (only started in the last month).
The data set I'm using currently only has around 35,000 polygons in it and it takes probably 20-30 mins to complete but I plan to be able to run this script on data sets of around 200,000 so definitely need some other option.
I'm not aiming to have this run in seconds as that's unrealistic, but do have a goal of having it run in around 5 minutes.