I have a QgsFeatureRequest() that filter all the features by an attribute. Is there any python function that could tell me how many features were filtered? I know I could create a list with this features and then count them. But I want a better way.

1 Answer 1


This is a quite short way:

vlayer.selectByExpression("here comes your expression")

If you stick to QgsFeatureRequest(), then you have to use a counter (I guess). After vlayer.getFeatures(QgsFeatureRequest("here comes your expression")), you will have a QgsFeatureIterator, which does not have method like featureCount().



This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .