[GRASS5] Re: [GRASSLIST:1549] Use of neighbourhood operator in r.mapcalc
glynn.clements at virgin.net
Thu Oct 23 19:21:39 EDT 2003
Roy Sanderson wrote:
> 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?
Prior to 5.0.2, the horizontal modifier for CELL (integer) maps was
effectively doubled (the shift was applied twice). This bug was fixed
in 5.0.2. Note that the bug was introduced when r.mapcalc was
completely re-written, somewhere around the time of the -pre3 release,
so this isn't applicable to 4.3.
A number of significant bugs have been fixed (in r.mapcalc and in
other programs) between -pre5 and the current 5.0.2 release. I
strongly recommend upgrading to either 5.0.2 or 5.0.3-RC5.
Aside: this operation seems to be sufficiently popular that we should
consider adding an option to either r.buffer or r.grow to support it.
Using r.mapcalc quickly becomes impractical if you want a buffer
larger than one cell.
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev