Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am new to GIS and have the following problem:

I have 2 layers: a point layer with a column that contains numbers (pollution index from specific measurement point) and a polygon layer with different regions.

And I want to answer the following question: what is 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?

Thank you very much!!

share|improve this question
1  
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 '13 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.

share|improve this answer
    
Thank you very much for your answer. Can you go into a bit more detail regarding the spatial join please? THX –  flimm Jun 19 '13 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. –  Ryan Garnett Jun 19 '13 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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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