I noticed some changes since qgis 2.8 but can't find any information about it. Let's say I have a very simple point layer loaded in QGIS, from a spatialite table. From this layer I select some points and want to count how many points I've got in my selection using a few PyQGIS lines. Very simple:

layer = qgis.utils.iface.activeLayer()
selection01 = layer.selectedFeatures()

What I've noticed is that if I select more than 999 features, nbrSelected still returns the correct number of points, but


returns 0... the list is empty.

This wasn't happenning with QGIS 2.6 (I just checked again), but only on 2.8 and 2.10.

I tried on 2 different computers, with the same result.

Is there another way of browsing more than 1000 selected features? I also tried with the processing (processing.features(layer)) but it acts as if my selection was empty as well (i.e. returns the complete content of my layer, not just the selection).


1 Answer 1


I tried this with a Spatialite layer now, same result. Interestingly, QGIS shows "SQLite error: Expression tree is too large (maximum depth 1000)" in the Spatialite log panel.

I've raised this issue on the mailing list and the SQLite bug should now be fixed in the latest developer version according to http://osgeo-org.1560.x6.nabble.com/Empty-selectedFeatures-list-td5219421.html

  • thanks very much for this Anita. As you mentioned this only happens with spatialite databases (even latest version). Not sure how/if I can try this fixed version of qgis... I may have to go back to my "old" v 2.6.1 to go on ;-). thanks again. Aug 13, 2015 at 8:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.