1

I'm using the population density raster from SEDAC (person/square km), I've clipped it to my area of interest (Vietnam) as shown in the picture below: enter image description here

In addition to this, I have a vector layer of the provinces of Vietnam: enter image description here For each province I have a unique id and the name of the province. Lastly, I have an Excel spreadsheet containing for each province, the waste production rate per person. I'd like to group the population data for each province, a bit like "join attributes by location" with a vector, but I'm unsure I can do this with raster files. I'm starting to use raster info; I've looked around but haven't found anything helpful.

  • You could vectorize the raster, though I don't know if the values are preserved, and then join the attributes of your existing shapefile to the one you created. – Erik Jan 22 at 10:53
  • @Erik I've done that yes, but I keep on getting an error message "The following layers were not correctly generated". The input layer is the raster. Band Number is Band 1 (grey) (my raster only has one band). And it keeps on failling.... – Tim56 Jan 22 at 10:58
2

I would actually do this in reverse - create a raster from the vector provinces map, making sure you have aligned the rasters exactly, so each cell is associated with both a single province value and a single population density value.

Once you have accomplished this, you can run the GRASS program r.univar which will give you statistics by the province cells, including the sum of the population density for each province, which will be the grouping you need.

You can then put these values into a spreadsheet, divide by your waste column, and then join that spreadsheet back to the original vector layer to create your visualisation.

Please note I haven't tried this myself and don't know if r.univar will be available in the GRASS QGIS plugin, but I hope you find the workflow useful.

| improve this answer | |
  • 1
    For anyone else who comes upon this, the QGIS Zonal Statistics tool will also perform this action without needing to rasterise the vector layer. – statto Jan 23 at 12:55

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.