I have a raster of population density and would like to intersect it with a polygon layer and have each polygon carry the average for the underlying raster cells. How would I go about this? I feel like they need to be intersected but what else?

enter image description here

  • the "negative dimensions not allowed" error might be a clue.. can you edit your question to include that message and the extra steps you took to get that message? (also, where did you get the raster data - is it SEDAC GPW ?).
    – Steven Kay
    Apr 26 '17 at 21:16
  • Yep this is SEDAC GPW. Fixed by downloading from original source. For some reason in raster I was provided coordinates had been changed to match pixels of raster.
    – Simon
    May 1 '17 at 19:17

This is basic Zonal statistics task.

You can find this in menu: Raster -> Zonal statistics -> Zonal statistics. This creates new attribute in polygon layer, carrying chosen calculation.

enter image description here

Other option is use Zonal statistics function from Processing toolbox

  • Except I want an average within each one of my custom cells. I'm still confused how I would go about intersecting the two different layers. Also I have no option for zonal stats (assume that would be raster calculator)
    – Simon
    Apr 26 '17 at 19:33
  • 1
    try Processing > Toolbox and type zonal into the search bar, it's under QGIS Geoalgorithms (I'm on QGIS 2.18, and the option seems to have been removed from the Raster menu). You'll want to select average and/or median. Zonal stats does all the intersecting for you.
    – Steven Kay
    Apr 26 '17 at 19:59
  • I'm getting error saying "negative dimensions not allowed". I know how to fix this for my vector layer but what's the best way of editing this for a raster layer?
    – Simon
    Apr 26 '17 at 20:25
  • The raster menu option is dependent on built-in plugin Zonal statistics plugin, maybe its just deactivated. Both options (menu and processing toolbox) works fine for me in 2.18. @Simon sorry I don't know whats causing this error.
    – Oto Kaláb
    Apr 26 '17 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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