I need to get the overall area of physically discrete areas of a raster layer up to a given cell count in QGIS. The following approach is what I've tried so far, but it seems a bit too complicated and I'm looking for a simpler approach.
- Use r.clump GRASS raster tool to get the physically discrete areas ("Clump also diagonal cells" ticked in my case).
- Use Raster layer zonal statistics tool to create the statistics table.
- Sort attribute table by cell count field (ascending).
- Select all rows up to the given cell count (in this particular case: cell count of the largest obvious sliver polygon equivalent).
- Get sum of area of all selected rows (I saved the selection to a new table layer for this).
An important part of a simpler approach that I have been thinking of is to check for the cell count in the Raster calculator and use it as value for the cells in the output, but I could not achieve this so far.
Just for illustration, here's the
r.clump result where every region has its own and distinct raster value:
The exercise is to get the cell count of all sliver polygon equivalents.