help with r.neighbors modification

Grass package grass at
Wed Jul 12 04:28:23 EDT 1995

Hi Dana,

I fear this will not earn me your undying gratitude, but have a look at 
r.mapcalc and the r.mapcalc tutorial. With a little bit of script-writing
you can produce the same results as r.neighbours, and more, since it allows
you to query and process any cell neighboring the cuurent cell (in any 
direction and at any distance) separately. Good luck,


P. Martijn van Leusen -------------------------------------------------------+
Leverhulme Research Fellow, The Wroxeter Hinterland Project                  |
University of Birmingham Field Archaeology Unit                              |
Edgbaston, Birmingham B15 2TT  Phone +44 121 414 5513  Fax +44 121 414 5516  |
E-mail P.M.van-Leusen at                                             |
> 	I am using hyperclustered TM imagery to map deciduous
>  forests in New England as part of the GAP Analysis program.  
> This treatment produces a large number of spectral classes which
>  we then reclass into our vegetation types with "i.infer".  I  found 
> that quantifying neighborhood associations increased our accuracy 
>  and have used "r.neighbors" to identify the most frequently 
> occurring spectral class around each pixel.  However, I need a 
> way to identify the second and third most frequent neighbors as 
> well and produce percentages of each if possible.  I have tried to do 
> this in the MIPS sml language without much luck, being among 
> the programmably challenged, and would prefer to use GRASS 
> because it's in the public domain.
> 	Could any of you help with a modification of "r.neighbors",
>  either with multilayer output or as a set of programs applied in 
> sequence.  Not only would you receive the undying gratitude of my 
> department, co-authors and self, but your efforts would be fully 
> credited in any subsequent publication.
> Dana Slaymaker
> Department of Forestry and Wildlife Management
> University of Massachusetts in Amherst
> dana at
> (413) 545-4853

More information about the grass-user mailing list