I have population distribution data as a raster layer and exposure contours as vector (polygon) layers. What I'd like to do is use the vector layer to estimate the population indicated from the raster layer that fall underneath the polygon.

Can someone shed some light on this?

If it isn't straight forward, I am not too bad with Python so I'd be more than comfortable writing something that does this.

  • 4
    Normally this is trivial: it's a "zonal sum" operation, which totals values within disjoint polygonal regions. But you have two problems. First, your exposure contours are surely nested--they overlap greatly. Second, many of the contour lines probably are not closed, and therefore do not adequately represent "polygons" at all. If you possibly can, you should obtain a raster representation of exposure (this was likely used to generate the contours in the first place). Comparing the two rasters will yield a highly detailed plot of total population exposed versus exposure threshold.
    – whuber
    Commented Nov 13, 2012 at 18:16

2 Answers 2


You could use the GRASS module v.rast.stats, which calculates univariate statistics from a raster map based on vector polygons and uploads the statistics to new attribute columns.

The v.rast.stats2 module is an optimised version that might be more suitable if you are working with large datasets.

Starspan is another option that allows one to do spatial analysis of raster data using vector features.


If you are familiar with R, you could also solve this problem with your favourite R editor, which is easy as pie.

For example like this:


ras <- raster(...)
pol <- readOGR(...)

extraction <- extract(ras,pol)
statistics <- lapply(extraction,table)
# Further analyze the data (mean, sum per polygon feature or sth. like that)

BTW: I am currently writing a new function for a qgis-plugin of mine, which could exactly do what you want. However, it could still take a bit until it is ready (in fact I first need to solve the following problem).


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.