# Calculating area of raster using QGIS?

I have this raster wich represent some areas of observation from 3 given points following a series of rules considering elevation and direction of the slope. Basically, the white-ish color represent no point can see this area (0); the orange area is seen from 1 point (1); and the brown area is seen by 2 points (2). Now, I have to calculate the area of each color, specialy the orange and brown ones, but I don't have a clue on how to do it. I tried to convert this raster to vector to calculate te area of the polygon; but when I do it there're lots of polygons and none of them seem to conservate the value of the pixel.

The raster I'm interested in was obtained by the cumulative viewshed tool.

Any idea on how to do it?

• Could you specify the tools you are using? Also, it looks like (correct my if I am wrong), a raster hillshade with polygons drawn on top? Or is that a raster drawn on top? Or is the entire thing just a png? In any case, what I usually do is clip what you don't want/set everything else to noData, vectorize the area, and calculate it from there. – Lennert De Feyter Oct 23 '17 at 0:42
• I'm using QGIS, I don't know if that's what you want to know. And about the raster, it's just a screenshot, but there're two different rasters; the one of the elevation and the other one which is the one I want to calculate the area. – Bernardo Oct 23 '17 at 0:44
• Please use the edit button beneath your question to revise it with any requested clarifications. – PolyGeo Oct 23 '17 at 1:02
• @LennertDeFeyter is correct, convert your raster to vector docs.qgis.org/2.6/en/docs/training_manual/complete_analysis/… then calculate area gis.stackexchange.com/questions/23355/… and for finesse summarize to a table gis.stackexchange.com/questions/43037/… which will be the area of the polygons. The only other way would be to get a count of all the cells by class then multiply by the area of a single cell, which could be done in python but would be more difficult. – Michael Stimson Oct 23 '17 at 1:13
• It seems that when you did the raster to vector you didn't specify a field to put the orange/brown values into.. Is the orange/brown raster a single raster or do you have an orange raster and a brown raster? I'm assuming that it's a single raster with 3 values: orange, brown and NoData. – Michael Stimson Oct 23 '17 at 1:15

I think you could use the `r.report` from the GRASS toolbox. I expect your raster data has something like NULL for no observation and an integer for the number of observation points. If not you could achieve it by "adding" your rasters The input of `r.report` is your raster data and report is areas for each value in the raster. Check the manual page of r.report Here the sceershot of the r.report in QGIS and the output.