In QGIS I have two layers:

  • a point layer with a column that contains numbers (pollution index from specific measurement point);
  • a polygon layer with different regions.

I want to find the average pollution for each region so I need compute the mean for all points in each region.

How can I do that in QGIS?

  • 3
    It may be worth noting that you are not proposing to compute the average pollution in each region: you are only asking how to compute the average measurement. The difference often is large, because measurement sites typically are set up in problem areas and therefore do not represent the entire region. To obtain the average in the region, the usual method is to interpolate the measurement values throughout that region (carefully, often using geostatistical procedures) and average the interpolated values.
    – whuber
    Jun 19, 2013 at 14:08

2 Answers 2


One way to do this is using a Spatial Join. You would do a spatial join with the point to the polygon layer. The point layer will need to have codes (ie: unique IDs, or a grouping ID system). When you do the spatial join you will have the polygon IDs, which will allow you to do calculations. With the data you can query out features based on the polygon IDs to the min, max, mean, etc. You can also look at using the Group Stats plugin for QGIS.

  • Thank you very much for your answer. Can you go into a bit more detail regarding the spatial join please? THX
    – flimm
    Jun 19, 2013 at 7:09
  • What areas would you like? You access the spatial join in QGIS from Vector - Data Management Tools - Join attributes by location. In the Join window the target layer will be the point layer, and the join vector will be the polygon layer. You have some options about the join, I would play around and analyse the outcome, but using points, you should be ok with the defaults. Jun 19, 2013 at 15:11

Here's how you can do averages, etc using the spatial database SpatiaLite. First import both of your layers into a spatialite DB. Let's call them "sensors" (the point layer) with a "pollution" column and "regions" (the polygons) with a "name" column. You can do this easily with the spatialite-gui, Import shapefile button.

Now this query will give you various statistics from the sensors for each polygon:

SELECT AVG(s.pollution) AS "Average Pollution", 
   MAX(s.pollution) AS "Maximum Pollution",
   COUNT(s.*) AS "Number of Sensors",
   r.name AS "Region Name" 
FROM sensors AS s JOIN regions AS r 
ON ST_Contains(r.geometry, s.geometry)
GROUP BY r.name

(Side note: If you have tens of thousands of points, you'll want to add a spatial index on the polygon table, and implement it in the query.)

Your Answer

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

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