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 2


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
    – user81524
    Commented 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.
    – Micha
    Commented May 16, 2017 at 6:17
  • Not able to use GRASS. Don't know how to operate it.
    – user81524
    Commented May 16, 2017 at 9:57

Micha details the approach I would take (+1). For 'fun' here are a couple of alternatives:

  1. 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.
  2. 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.

Your Answer

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

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