In QGIS, is there a way to count the number of vertices of polygons and lines in a given layer, and create a separate field containing these values?

I suspect it's a function somewhere in the field calculator but I can't find it.

4 Answers 4


Number of points - just simple formula in QGIS field calculator:


See the screenshot below: in this case, the number of vertices of each feature is added to the field "vertex" in the attribute table. Alternatively, you can create also "Create a new field" and get results there.

enter image description here

  • Am I first creating a field called "vertex" and then summarizing that field (using what tool?) after the field calculation? It might be helpful to add that information to the answer.
    – Kristen G.
    Mar 2, 2020 at 14:45
  • 1
    Thanks @Kristen G., I updated the answer withthat info.
    – jurajb
    Mar 3, 2020 at 17:44

You can use the excellent 'Vertices Counter' plugin which does exactly this. You can see the step-by-step guide here:

Counting Number of Vertices in a Layer

  • Thanks Ujaval. I'm afraid python kind of scares me but I just got around to looking at your blog today and it works! Thanks very much and I'm sorry for not looking at this sooner. R
    – crichard75
    Nov 30, 2012 at 15:20
  • 1
    It seems that this plugin is no longer available in QGIS 3.0+ Dec 21, 2018 at 19:53
  • Correct. See the other answer where you can achieve the same using a formula in the field calculator num_points($geometry) Dec 28, 2018 at 6:19

As times go by and version changes, some hints concerning the recent QGIS versions 3.2 and 2.18.22 LTR (by Aug. 7th, 2018). In QGIS 2.18 the Vertices Counter plugin works as usual, but seems not yet been ported to QGIS 3. But fortunally, there is another solution available in field calculator that you expected to find nearly six years ago.

Two relevant functions are available:

nodes_to_points() creates MULTIPOINT geometry of the source geoemtries nodes and

num_geometries() counts the geometries in a collection or MULTI... geometry

so combining these functions and creating a virtual field will accomplish this task:

enter image description here

resulting in

enter image description here


Look in the vector menu, there is a "extract nodes" tool.

  • Thanks Giovanni but it’s not quite what I’m looking for. I just tried “extracting nodes” and counting “Points in Polygon”. I’m afraid the shapefile I am dealing with consists of multiple abutting polygons. The polygons were created by snapping to vertex. Extracting nodes creates multiple overlapping points which end up in the count. I’m looking for a way to count the nodes of each individual polygon, so a square polygon may have 4 nodes, not the potential 16 nodes or more from abutting polygons.
    – crichard75
    Aug 29, 2012 at 19:07
  • Then you need to import your data into a fully topological gis = GRASS, you can do it in qgis using the grass plugin. Aug 30, 2012 at 18:56

Your Answer

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

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