I have a raster TIFF containing a habitat map. The raster, with resolution of 10m x 10m, indicates a different code for each pixel (say code 1 = woodland, 2 = grassland, 3 = urban area. I've got another vector files containing multiple polygons indicating several demarcated area.

For each polygon I want the information of which percentage of woodland, grassland, urban area etc. i.e. different type of habitat according to the raster TIFF.

I am using QGIS 3.22. How can I do it?

1 Answer 1

  1. Zonal Histogram. Output will contain one column with pixel count for each raster value
  2. Multiple Field Calculators or one Refactor fields to create new columns with percentages for each class.

enter image description here

  • Thanks. The answer helps me a lot. OTOL for Refactor Fields do we have an option to import an excel or CSV file that contains Field Mapping attributes including Source Expression, Name, Type, Length. So that we don't need to input them manually? May 8, 2022 at 16:34
  • Use load fields from to load all existing fields from Zonal Histogram. I dont think there's a way of loading expression to calculate the percentages. Do you have many codes/values?
    – BERA
    May 8, 2022 at 16:36
  • Thanks for the information! But how exactly can I run the python script to the layer of polygon with habitat data imported? May 9, 2022 at 0:59
  • 1
    Thanks for your answers. I found another way that I copied the data of attribute table of demarcated area containing informations of habitat and render the data in excel. Then I put the data back to QGIS and it works! May 9, 2022 at 14:17

Your Answer

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

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