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

NAME

6       r.mfilter  - Raster map matrix filter.
7

KEYWORDS

9       raster, map algebra
10

SYNOPSIS

12       r.mfilter
13       r.mfilter help
14       r.mfilter  [-qz]  input=name  output=name filter=name  [repeat=integer]
15       [title=string]   [--overwrite]  [--verbose]  [--quiet]
16
17   Flags:
18       -q
19           Quiet
20
21       -z
22           Apply filter only to zero data values
23
24       --overwrite
25           Allow output files to overwrite existing files
26
27       --verbose
28           Verbose module output
29
30       --quiet
31           Quiet module output
32
33   Parameters:
34       input=name
35           Name of input raster map
36
37       output=name
38           Name for output raster map
39
40       filter=name
41           Name of filter file
42
43       repeat=integer
44           Number of times to repeat the filter
45           Default: 1
46
47       title=string
48           Output raster map title
49

DESCRIPTION

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

FILTERS

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

EXAMPLE FILTER FILE

118
119             TITLE      3x3 average, non-zero data only, followed by 5x5 aver‐
120       age
121            MATRIX    3
122            1 1 1
123            1 1 1
124            1 1 1
125            DIVISOR   0
126            TYPE      P
127            MATRIX    5
128            1 1 1 1 1
129            1 1 1 1 1
130            1 1 1 1 1
131            1 1 1 1 1
132            1 1 1 1 1
133            DIVISOR   25
134            TYPE      P
135
136

HOW THE FILTER WORKS

138       The filter process produces a new category value for each cell  in  the
139       input  raster map layer by multiplying the category values of the cells
140       in the n x n neighborhood around the center cell by  the  corresponding
141       matrix  value and adding them together.  If a divisor is specified, the
142       sum is divided by this divisor, rounding to the nearest integer.  (If a
143       zero  divisor was specified, then the divisor is computed for each cell
144       as the sum of the MATRIX values where the corresponding input  cell  is
145       non-zero.)
146
147       If  more  than  one filter step is specified, either because the repeat
148       value was greater than one or because the filter  file  contained  more
149       than  one  matrix,  these  steps are performed sequentially. This means
150       that first one filter is applied to the entire input raster  map  layer
151       to  produce  an intermediate result; then the next filter is applied to
152       the intermediate result to produce another intermediate result;  and so
153       on,  until  the final filter is applied.  Then the output cell is writ‐
154       ten.
155

NOTES

157       If the resolution of the geographic region does not agree with the res‐
158       olution  of the raster map layer, unintended resampling of the original
159       data may occur.  The user should be sure that the geographic region  is
160       set properly.
161

SEE ALSO

163       g.region, r.clump, r.neighbors
164

AUTHOR

166       Michael Shapiro, U.S.Army Construction Engineering Research Laboratory
167
168       Last changed: $Date: 2007-03-20 04:30:13 +0100 (Tue, 20 Mar 2007) $
169
170       Full index
171
172       © 2003-2008 GRASS Development Team
173
174
175
176GRASS 6.3.0                                                       r.mfilter(1)
Impressum