I need a list of all values of a certain field in a QGIS dataset. To get this, I am using
for festure in layer.getFeatures(): value=feature[fieldname]
This is kind of working, but I have two issues with it, they may have the same solution:
- I want the data sorted by id, it seems to me that some of the points are not coming in the correct order.
- It seems rather slow. I have a dataset with a few thousand records and it uses several seconds to go through it.
(the base dataset is a PostGIS table if that matters)
So I have these questions:
- Is there any way to sort the data returned by getFeatures()?
- Is there any way to speed up getFeatures() or
- Should/could I use any other way of getting all values from a field?