Counting Number of Vertices in a Layer

Note

For QGIS3, there is much simple solution using the expression num_points($geometry). See this answer for details.

QGIS doesn’t have a built-in function to calculate number of vertices for each feature in a layer. But a very handy plugin called Vertices Counter fills this gap and adds a few handy features as well.

Procedure

  1. Find and install the Vertices Counter plugin. See Using Plugins for details on installing plugins in QGIS.

../_images/1172.png
  1. Load any polygon or line layer in QGIS. Go to Vector ‣ Vertices Counter ‣ Vertices Counter.

../_images/2141.png
  1. By default, the active layer will be selected under the Layer Selection. You may select any other loaded layers or open layer directly from disk as well. The plugin has an option called Create new column which can add an number of vertices as an attribute for each feature. This is handy for a lot of use cases, so we can select that option. Now click on the Count Vertices button and the Results section will be populated with vertex count for each feature. You can even see the Total Vertices displayed on the side.

../_images/383.png
  1. Back in the main QGIS window, let’s verify if a new column was added to our layer. Right-click the layer and select Open Attribute Table.

../_images/449.png
  1. As you will notice, a column named Vertices will be added at the end with values representing the vertex count for each feature. This column can come in handy if you want to do a query such as Select all features with Vertices > X.

../_images/543.png

If you want to give feedback or share your experience with this tutorial, please comment below. (requires GitHub account)