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

NAME

6       r.mfilter  - Raster file matrix filter.
7

KEYWORDS

9       raster
10

SYNOPSIS

12       r.mfilter
13       r.mfilter help
14       r.mfilter [-qz] input=string output=string filter=string  [repeat=inte‐
15       ger]   [title="phrase"]   [--overwrite]
16
17   Flags:
18       -q  Quiet
19
20       -z  Apply filter only to zero data values
21
22       --overwrite
23
24   Parameters:
25       input=string
26           Name of the input raster file
27
28       output=string
29           Name of the output raster file
30
31       filter=string
32           Name of the filter file
33
34       repeat=integer
35           Number of times to repeat the filter Default: 1
36
37       title=
38           Output raster file title
39

DESCRIPTION

41       r.mfilter filters the raster input to produce the raster output accord‐
42       ing to the matrix filter designed by the user (see FILTERS below).  The
43       filter is applied repeat times (default value is 1).  The output raster
44       map  layer  can be given a TITLE if desired.  (This TITLE should be put
45       in quotes if it contains more than one word.)  With -z flag the  filter
46       is  applied only to zero category values in the input raster map layer.
47       The non-zero category values are not changed.  Note that  if  there  is
48       more  than  one  filter  step, this rule is applied to the intermediate
49       raster map layer -- only zero category values  which  result  from  the
50       first  filter  will  be  changed.   In  most cases this will NOT be the
51       desired result. Hence -z should be used only with single step filters.
52
53       The filter parameter defines the name of an existing, user-created UNIX
54       ASCII  file  whose  contents  is a matrix defining the way in which the
55       input file will be filtered. The  format  of  this  file  is  described
56       below, under FILTERS.
57
58       The  repeat  parameter  defines the number of times the filter is to be
59       applied to the input data.
60

FILTERS

62       The filter file is a normal UNIX ASCII file designed by the  user.   It
63       has the following format:
64            TITLE      TITLE
65            MATRIX     n
66                         .
67            n lines of n integers
68                         .
69            DIVISOR    d
70            TYPE        S/P
71
72
73       TITLE  A  one-line  TITLE for the filter.  If a TITLE was not specified
74              on the command line, it can be specified here.  This TITLE would
75              be used to construct a TITLE for the resulting raster map layer.
76              It should be a one-line description of the filter.
77
78       MATRIX The matrix (n x n) follows on the next n lines.  n  must  be  an
79              odd  integer greater than or equal to 3.  The matrix itself con‐
80              sists of n rows of n integers.  The integers must  be  separated
81              from each other by at least 1 blank.
82
83       DIVISOR
84              The  filter  divisor  is d.  If not specified, the default is 1.
85              If the divisor is zero (0), then the divisor is dependent on the
86              category  values  in  the neighborhood (see HOW THE FILTER WORKS
87              below).
88
89       TYPE   The filter type.  S means sequential, while P mean parallel.  If
90              not specified, the default is S.
91
92       Sequential filtering happens in place.  As the filter is applied to the
93       raster map layer, the category values that were changed in  neighboring
94       cells  affect  the  resulting  category value of the current cell being
95       filtered.
96
97       Parallel filtering happens in such a way that the original  raster  map
98       layer category values are used to produce the new category value.
99
100       More  than  one  filter may be specified in the filter file.  The addi‐
101       tional filter(s) are described just like the first.  For  example,  the
102       following describes two filters:
103

EXAMPLE FILTER FILE

105
106             TITLE      3x3 average, non-zero data only, followed by 5x5 aver‐
107       age
108            MATRIX    3
109            1 1 1
110            1 1 1
111            1 1 1
112            DIVISOR   0
113            TYPE      P
114            MATRIX    5
115            1 1 1 1 1
116            1 1 1 1 1
117            1 1 1 1 1
118            1 1 1 1 1
119            1 1 1 1 1
120            DIVISOR   25
121            TYPE      P
122
123

HOW THE FILTER WORKS

125       The filter process produces a new category value for each cell  in  the
126       input  raster map layer by multiplying the category values of the cells
127       in the n x n neighborhood around the center cell by  the  corresponding
128       matrix  value and adding them together.  If a divisor is specified, the
129       sum is divided by this divisor, rounding to the nearest integer.  (If a
130       zero  divisor was specified, then the divisor is computed for each cell
131       as the sum of the MATRIX values where the corresponding input  cell  is
132       non-zero.)
133
134       If  more  than  one filter step is specified, either because the repeat
135       value was greater than one or because the filter  file  contained  more
136       than  one  matrix,  these  steps are performed sequentially. This means
137       that first one filter is applied to the entire input raster  map  layer
138       to  produce  an intermediate result; then the next filter is applied to
139       the intermediate result to produce another intermediate result;  and so
140       on,  until  the final filter is applied.  Then the output cell is writ‐
141       ten.
142

NOTES

144       If the resolution of the geographic region does not agree with the res‐
145       olution  of the raster map layer, unintended resampling of the original
146       data may occur.  The user should be sure that the geographic region  is
147       set properly.
148

SEE ALSO

150       g.region, r.clump, r.neighbors
151

AUTHOR

153       Michael Shapiro, U.S.Army Construction Engineering Research Laboratory
154
155       Last changed: $Date: 2003/05/06 14:04:17 $
156
157       Full index
158
159
160
161GRASS 6.2.2                                                       r.mfilter(1)
Impressum