[GRASS-user] how to count number of occurrences of a specific
category value in the neighborhood of a given pixel
Moritz Lennert
mlennert at club.worldonline.be
Wed Nov 23 18:11:34 EST 2011
On 23/11/11 17:41, Marcello Gorini wrote:
>
> Moritz:
>
> Hello,
>
> Does anyone see an easy way to count the number of times a specific
> category value occurs in a given neighborhood of a central pixel ?
>
> As always, there is surely a better way in GRASS (probably one single
> command), but you could binarize your map (1 for your desired category
> and zero for everything else) and then use r.neighbors method=sum
> size=desired_neighborhood.
>
> The result would be the desired count.
Thanks ! Yes, I came upon this solution myself in the meanwhile and I
think it is the only one. Maybe something to script into a nice little
frontend to r.neighbors where you give the map and the desired category
and you receive a map of numbers of neighbours in return.
Moritz
More information about the grass-user
mailing list