1r.neighbors(1)                Grass User's Manual               r.neighbors(1)
2
3
4

NAME

6       r.neighbors   -  Makes each cell category value a function of the cate‐
7       gory values assigned to the cells around it, and stores new cell values
8       in an output raster map layer.
9

KEYWORDS

11       raster
12

SYNOPSIS

14       r.neighbors
15       r.neighbors help
16       r.neighbors [-aq] input=string output=string method=string size=integer
17       [title="phrase"]   [--overwrite]
18
19   Flags:
20       -a  Do not align output with the input
21
22       -q  Run quietly
23
24       --overwrite
25
26   Parameters:
27       input=string
28           Name of existing raster file
29
30       output=string
31           Name of the new raster file
32
33       method=string
34           Neighborhood operation  Options:  average,median,mode,minimum,maxi‐
35           mum,stddev,sum,variance,diversity,interspersion
36
37       size=integer
38           Neighborhood size Options: 1,3,5,7,9,11,13,15,17,19,21,23,25
39
40       title=
41           Title of the output raster file
42

DESCRIPTION

44       r.neighbors looks at each cell in a raster input file, and examines the
45       values assigned to the cells in some user-defined "neighborhood" around
46       it.  It outputs a new raster map layer in which each cell is assigned a
47       value that is some (user-specified) function  of  the  values  in  that
48       cell's  neighborhood.  For example, each cell in the output layer might
49       be assigned a value equal to the average of the values appearing in its
50       3 x 3 cell "neighborhood" in the input layer.
51
52       The program will be run non-interactively if the user specifies program
53       arguments (see OPTIONS) on the command line.  Alternately, the user can
54       simply type r.neighbors on the command line, without program arguments.
55       In this case, the user will be prompted for flag settings and parameter
56       values.
57

OPTIONS

59       The user must specify the names of the raster map layers to be used for
60       input and output, the method used to analyze neighborhood values (i.e.,
61       the  neighborhood  function or operation to be performed), and the size
62       of the neighborhood.  Optionally, the user can also specify  the  TITLE
63       to  be  assigned to the raster map layer output, elect to not align the
64       resolution of the output with that of the input (the  -a  option),  and
65       elect  to  run  r.neighbors quietly (the -q option).  These options are
66       described further below.
67
68       Neighborhood Operation Methods: The  neighborhood  operators  determine
69       what  new value a center cell in a neighborhood will have after examin‐
70       ing values inside its neighboring cells.  Each cell  in  a  raster  map
71       layer  becomes  the  center  cell of a neighborhood as the neighborhood
72       window moves from cell to cell throughout the map  layer.   r.neighbors
73       can perform the following operations:
74
75       average
76              The  average  value  within  the neighborhood.  In the following
77              example, the result would be:
78              (7*4 + 6 + 5 + 4*3)/9 = 5.66
79              The result is rounded to the nearest integer (in this case 6).
80
81       median The value found half-way through a list  of  the  neighborhood's
82              values, when these are ranged in numerical order.
83
84       mode   The most frequently occurring value in the neighborhood.
85
86       minimum
87              The minimum value within the neighborhood.
88
89       maximum
90              The maximum value within the neighborhood.
91                     Raw Data     Operation     New Data
92                 ----------------          ----------------
93                 | 7  | 7  |  5 |          |    |    |    |
94                 |----|----|----| average  |----|----|----|
95              |    |  6 |    |
96                 |----|----|----|          |----|----|----|
97                 | 7  | 6  |  4 |          |    |    |    |
98                 |----|----|----|          |----|----|----|
99
100
101       stddev The  statistical  standard deviation of values within the neigh‐
102              borhood (rounded to the nearest integer).
103
104       sum    The sum of values within the neighborhood.
105
106       variance
107              The statistical  variance  of  values  within  the  neighborhood
108              (rounded to the nearest integer).
109
110       diversity
111              The  number of different values within the neighborhood.  In the
112              above example, the diversity is 4.
113
114       interspersion
115              The percentage of cells containing values which differ from  the
116              values  assigned to the center cell in the neighborhood, plus 1.
117              In the above example, the interspersion is:
118              5/8 * 100 + 1 = 63.5
119              The result is rounded to the nearest integer (in this case  64).
120              ERROR .RE
121
122       Neighborhood  Size:  The  neighborhood  size specifies which cells sur‐
123       rounding any given cell fall into the neighborhood for that cell.   The
124       size  must be an odd integer.  Options are:  1, 3, 5, 7, 9, 11, 13, 15,
125       17, 19, 21, 23, and 25.  For example,
126                                     _ _ _
127                                    |_|_|_|
128         |_|_|_|
129                                    |_|_|_|
130
131
132       -a     If specified, r.neighbors will not align the output  raster  map
133              layer  with that of the input raster map layer.  The r.neighbors
134              program works in the current geographic region.   It  is  recom‐
135              mended,  but not required, that the resolution of the geographic
136              region be the same as that of the raster map layer.  By default,
137              if  unspecified,  r.neighbors will align these geographic region
138              settings.
139
140       -q     If specified, r.neighbors will  run  relatively  quietly  (i.e.,
141              without  printing  to  standard  output  notes  on the program's
142              progress).  If unspecified, the program will print  messages  to
143              standard output by default.
144

NOTES

146       The r.neighbors program works in the current geographic region with the
147       current mask, if any.  It is recommended, but not  required,  that  the
148       resolution  of  the geographic region be the same as that of the raster
149       map layer.  By default, r.neighbors will align these geographic  region
150       settings.   However, the user can elect to keep original input and out‐
151       put resolutions which are not aligned by specifying this  (e.g.,  using
152       the -a option).
153
154       r.neighbors  copies  the  GRASS  color  files associated with the input
155       raster map layer for those output map layers  that  are  based  on  the
156       neighborhood  average,  median,  mode,  minimum,  and maximum.  Because
157       standard deviation, variance, diversity, and interspersion are indices,
158       rather  than  direct correspondents to input values, no color files are
159       copied for these map layers.  (The user should note that  although  the
160       color file is copied for averaged neighborhood function output, whether
161       or not the color file makes sense for the output will be  dependent  on
162       the input data values.)
163

SEE ALSO

165       g.region
166       r.clump
167       r.mapcalc
168       r.mfilter
169       r.support
170

AUTHOR

172       Michael Shapiro, U.S.Army Construction Engineering Research Laboratory
173
174       Last changed: $Date: 2006/04/13 19:01:37 $
175
176       Full index
177
178
179
180GRASS 6.2.2                                                     r.neighbors(1)
Impressum