Is it possible to run "selectbyexpression" in a standalone PyQGIS script? Inside QGIS, I was using iface to add the map to the interface and now I don't know how to run it without using iface.
Vince
20.5k16 gold badges49 silver badges65 bronze badges
1 Answer 1
You could use an expression to get the only the features you want.
request = QgsFeatureRequest().setFilterExpression('my_field > 20')
for feature in vector_layer.getFeatures(request):
see also https://nyalldawson.net/2016/10/speeding-up-your-pyqgis-scripts/
answered Aug 6, 2023 at 7:10
Explore related questions
See similar questions with these tags.
lang-py