Friday, 4 December 2015

qgis - How to calculate raster statistics for each values in a band?


I have one raster scene that contains one band with multiple pixel values (0-14). Each values represent deforestation in certain year (0=no tree cover loss, 1=loss in 2001, 2=loss in 2002, and so on) and I need to calculate the deforestation statistics for each years (e.g. statistics for each pixel values in that scene).


I've tried using Zonal Statistics, but it only gives me a lump of all values (total count in zonal statistic = sum of all values). What I need is to count how many pixels have value '1', '2', and so on. Any suggestion on what tool(s) to use? Properties of the scene. It only has 1 band, and it contains value of 0-14 (0=no tree loss, 1=loss in year 2001, ..., 14=loss in year 2014)



Answer



You can use Zonal Raster Statistics (also called Zonal Grid) tool to count the number of pixel in each class. The tool will create a new CSV file with the number of pixels for each category.


The only required parameter is the classified image (Zonal Grid) that contains the categories you want to calculate.


In the following example, I have a land use raster with 8 classes. When I run Zonal Raster Statistics tool, I got the following result:


enter image description here



Here is the output:


enter image description here


The tool can be found from Processing toolbox -> SAGA -> Geostatistics -> Zonal Raster Statistics


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...