Counting points in polygons with a QGIS processing model

What is the easiest way to calculate statistics for your vector data in QGIS? I usually solve the problems with a processing model, see the previous article, Processing geodata with a qgis model. In this case, I wanted a model for calculating the number of points within each polygon. As usual, there are several steps involved, such as filtering, dropping/renaming attributes, sorting the result and using a model is a convenient way of including all of these steps in a single process. The whole model looks like this:

A few notes:

1) “Filter features” expects you to manually enter the search string, in my case “KATEGORI” = ‘Järnvägsstation’. Use “” for the attribute name and ‘ ‘ for the attribute values.

2) “Refactor fields” is somewhat coplex to use, but it does the job. My configuration was this:

3) I use “Order by expression” to sort the result by the municipality name, so the string is simply “Kommunnamn”.

This offers a solution that is fairly easy to set up and running the model is very quick, the processing is done in a few seconds.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please reload

Please Wait