3

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?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Nina
  • 31
  • 3

1 Answers1

5

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?

BERA
  • 72,339
  • 13
  • 72
  • 161