[GRASS-user] how to count number of occurrences of a specific category value in the neighborhood of a given pixel

Marcello wrote:

As always, there is surely a better way in GRASS
(probably one single command),

"many roads lead to Rome" as the saying goes..

but you could binarize your map (1 for your
desired category and zero for everything else)

for this step, r.reclass will make things much
faster and save disk space too.

and then use r.neighbors method=sum
size=desired_neighborhood.

The result would be the desired count.

Hamish