[GRASS-user] r.neighbors with a custom mode calculation?

Don MacQueen macq at llnl.gov
Mon Mar 8 19:30:56 EST 2010


I'm pretty new to GRASS, and would appreciate some help/guidance/suggestions:

I have been smoothing a raster with r.neighbor, as in this example:

   r.neighbors input=alandcov at PERMANENT output=alandcov_smooth 
method=mode size=45 {title=Smoothed}

The raster values are integers representing qualitative categories.

I'd like to modify the smoothing to exclude a particular value. 
Specifically, if a cell (is that the right term?) has a particular 
value, say 11, then I want to exclude it, as follows:

  -  if the center of the neighborhood = 11, leave it unchanged (do 
not calculate the mode, just return 11)
  -  if the center is not 11, calculate the mode, but exclude any 
points in the neighborhood whose value = 11 (that is, take the mode 
only of points not equal to 11)

The real goal is to preserve boundaries between 11 and not 11. This 
is a land cover raster; 11 represents water, and I would like the 
smoothing to not change water to land or vice versa.

It seems like it might be possible to do it by creating a mask, 
smoothing the masked raster, and then putting the 11's back in maybe 
using r.mapcalc, but the details are a bit tough for me to put 
together, as a GRASS newbie.

Thanks for any suggestions
-Don
-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
--------------------------------------


More information about the grass-user mailing list