I have an ASCII grid file with different colored pixels (red, green, yellow and two intermediate yellow colors) and want to determine the total area covered by each [species distribution model result] category of colored pixel in QGIS. How should I Proceed?
2 Answers
One easy option is the r.stats
module in GRASS. Assuming the ASCII raster is categorized (5 categories with a different value for each), then the -a
option to r.stats
outputs total area for each category.
-
Thanks to both Micha and Mappa. But if this ASCII file converted into a grid file using DIVA GIS then it depicts banded colours, with some values are these values could be used to calculate area May 15, 2017 at 18:45
-
Not sure I understand. What is the purpose of DIVA here? I thought you already have an ASCII Grid raster. No need to convert anything, just import into GRASS and run
r.stats
.– MichaMay 16, 2017 at 6:17 -
Micha details the approach I would take (+1). For 'fun' here are a couple of alternatives:
- Open the raster properties, go to the Histopgram tab and click recompute histogram if necessary. There you will see the frequency of each value. Since this is an ascii raster it will be single band, so simply read the frequency for each value and multiply by the pixel area.
- Convert the raster to polygons (could be slow if your raster is huge). Dissolve by value resulting in a polygon layer with five multipolygons. Area is an attribute of polygons so you could either click on a polygon with the query tool and have it tell you, or use the field calculator to make a column to contain the value.