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.


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


enter image description here


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 '12 at 15:20
  • It seems that this plugin is no longer available in QGIS 3.0+ – user3386170 Dec 21 '18 at 19:53
  • Correct. See the other answer where you can achieve the same using a formula in the field calculator num_points($geometry) – spatialthoughts Dec 28 '18 at 6:19

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 '12 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. – Giovanni Manghi Aug 30 '12 at 18:56

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


if you or anyone are interested with arcmap , this page - HowTo: Count the vertices for line or polygon features in ArcMap - can help you...


1. Right-click the layer to be evaluated in the Table of Contents and click Open 
Attribute Table.
2. From the Table Options drop-down, click Add Field to add a new field to the table.
3. Name the field VxCount and select Long Integer for the field type. Click OK.
4. Right-click the heading of the new field and click Field Calculator.

    The geoprocessing tool, Calculate Field, can also be used to populate the field.

5. Under Parser, select Python.
6. In the main expression box, set:

    VxCount = !shape!.pointcount

7. Click OK.

i hope it helps you...

  • 1
    Thanks Aragon. I'm going to try do this in QGIS as I don't have regular access to arcmap. R – crichard75 Nov 30 '12 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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