[GRASSLIST:1549] Use of neighbourhood operator in r.mapcalc

Roy Sanderson R.A.Sanderson at newcastle.ac.uk
Thu Oct 23 13:27:09 EDT 2003


Hello Grass-users

I have a raster map with over 200 points, each with a different category
value, and I need to buffer around each point by one pixel, but retaining
the original category value in the buffered cells.  Since r.grow and
r.buffer assign new categories to the buffered cells, I've tried to use the
neighbourhood operators in r.mapcalc.  Using a script, containing the line

r.mapcalc buffmap = if(oldmap, oldmap, \
 if(oldmap[0,-1], oldmap[0,-1] \
  if(oldmap[0,1], oldmap[0,1] \
   if(oldmap[-1,0], oldmap[-1,0] \
    if(oldmap[1,0], oldmap[1,0])))))

which is very similar to the example script in Shapiro & Westervelt's
r.mapcalc guide.  The puzzle is that whilst this works fine in Grass 4.3,
in Grass5.0pre5 the buffering is incomplete, with the western buffer pixel
on cell too far to the west.  Have I overlooked something?

Many thanks for your help
Roy

----------------------------------------------------------------------------
Roy Sanderson
Centre for Life Sciences Modelling
Porter Building
University of Newcastle
Newcastle upon Tyne
NE1 7RU
United Kingdom

Tel: +44 191 222 7789

r.a.sanderson at newcastle.ac.uk
http://www.ncl.ac.uk/clsm

----------------------------------------------------------------------------




More information about the grass-user mailing list