I have a vector layer with say 100.000 features. I would like to get the N'th feature from the layer when sorted by an attribute field name:
Feature 1 Feature 2 : Feature N <-- : Feature 99.999 Feature 100.000
layer.getFeatures(...) I can sort the features:
request = QgsFeatureRequest() request.addOrderBy(field_name) feature_iterator = layer.getFeatures(request)
Then I can extract the N'th feature by:
feature = list(feature_iterator)[N - 1]
It takes some time to make a list of 100.000 features. I can limit the number of features since I don't need to request the features coming after N:
But if I need feature N=99.999 I still need to request almost all of the features.
Can I get the N'th feature more efficiently?