The program will be run non-interactively if the user specifies program arguments (see OPTIONS) on the command line. Alternately, the user can simply type r.neighbors on the command line, without program arguments. In this case, the user will be prompted for flag settings and parameter values.
Neighborhood Operation Methods: The neighborhood operators determine what new value a center cell in a neighborhood will have after examining values inside its neighboring cells. Each cell in a raster map layer becomes the center cell of a neighborhood as the neighborhood window moves from cell to cell throughout the map layer. r.neighbors can perform the following operations:
Raw Data Operation New Data
---------------- ----------------
| 7 | 7 | 5 | | | | |
|----|----|----| average |----|----|----|
| 4 | 7 | 4 |--------->| | 6 | |
|----|----|----| |----|----|----|
| 7 | 6 | 4 | | | | |
|----|----|----| |----|----|----|
Neighborhood Size:
_ _ _
|_|_|_|
3 x 3 neighborhood ---> |_|_|_|
|_|_|_|
Matrix weights:
r.neigbors in=input.map out=output.map size=3 weight=weights.txtThe contents of the weight.txt file:
3 3 3 1 4 8 9 5 3This corresponds to the following 3x3 matrix:
-------
|3|3|3|
-------
|1|4|8|
-------
|9|5|3|
-------
The exact masks for the first few neighborhood sizes are as follows:
3x3 . X . 5x5 . . X . . 7x7 . . . X . . .
X O X . X X X . . X X X X X .
. X . X X O X X . X X X X X .
. X X X . X X X O X X X
. . X . . . X X X X X .
. X X X X X .
. . . X . . .
9x9 . . . . X . . . . 11x11 . . . . . X . . . . .
. . X X X X X . . . . X X X X X X X . .
. X X X X X X X . . X X X X X X X X X .
. X X X X X X X . . X X X X X X X X X .
X X X X O X X X X . X X X X X X X X X .
. X X X X X X X . X X X X X O X X X X X
. X X X X X X X . . X X X X X X X X X .
. . X X X X X . . . X X X X X X X X X .
. . . . X . . . . . X X X X X X X X X .
. . X X X X X X X . .
. . . . . X . . . . .
The -c flag and the weights parameter are mutually exclusive. Any use of the two together will produce an error. Differently-shaped neighborhood analysis windows may be achieved by using the weight= parameter to specify a weights file where all values are equal (for method=sum, the sum of the weights should be 1). The user can also vary the weights at the edge of the neighborhood according to the proportion of the cell that lies inside the neighborhood circle, effectively anti-aliasing the analysis mask.
For aggregates where a weighted calculation isn't meaningful (specifically: minimum, maximum, diversity and interspersion), the weights are used to create a binary mask, where zero causes the cell to be ignored and any non-zero value causes the cell to be used.
r.neighbors copies the GRASS color files associated with the input raster map layer for those output map layers that are based on the neighborhood average, median, mode, minimum, and maximum. Because standard deviation, variance, diversity, and interspersion are indices, rather than direct correspondents to input values, no color files are copied for these map layers. (The user should note that although the color file is copied for average neighborhood function output, whether or not the color file makes sense for the output will be dependent on the input data values.)
Last changed: $Date: 2008-02-24 16:53:45 +0100 (Sun, 24 Feb 2008) $