I want the total feature count of all the features in all my layers. Doing it manually in QGIS 2.18.16 is too slow.

I have been trying PyQGIS, but am not good with PyQGIS.

Any tips?

closed as off-topic by PolyGeo May 3 '18 at 6:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


List the vector layers and sum their feature counts:

sum([l.featureCount() for l in iface.mapCanvas().layers() if l.type()==QgsMapLayer.VectorLayer])

enter image description here

See PyQGIS: How to get the list of valid layers in TOC? and How do I get feature count of a QgsVectorLayer?

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