1

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
asked Jul 27, 2023 at 15:39

1 Answer 1

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.