- Replaces the values of pixels of a given category with values of the surrounding pixels.
r.fill.category [-k] input=name output=name category=integer [nsize=integer] [maxiter=integer] [animationfile=name] [quality=integer] [--overwrite] [--help] [--verbose] [--quiet] [--ui]
- Keep intermediate maps
- Allow output files to overwrite existing files
- Print usage summary
- Verbose module output
- Quiet module output
- Force launching GUI dialog
- input=name [required]
- Name of input raster map
- output=name [required]
- Name for output raster map
- category=integer [required]
- Category to replace
- Neighborhood size in pixel
- Default: 19
- Maximum number of iterations
- Options: 1-999
- Default: 100
- Name for animation output file
- Quality factor for animation (1 = highest quality, lowest compression)
- Options: 1-5
- Default: 3
replaces the values of pixels of a given category with values
of the surrounding pixels and stores the output in
a new raster map layer. The module can be used to eliminate one category from a raster map
without leaving areas with NULL values, like for example when using r.reclass.area
Areas with the given category are eroded and their pixels
value is replaced with the values given by the mode of the surrounding pixels.
r.fill.category iteratively applies r.neighbors and r.mapcalc until no pixel of the category
to replace is left or the maximum number of iterations is reached.
Optionally, r.fill.category can create an MPEG file animating the replacement process.
The user controls the process by setting the neighborhood size
in pixels and the maximum number of iterations
The neighborhood size controls the size of the moving window where the mode of the values is used to assign a value to the pixels of the category to be replaced. Large values of the neighborhood size can speed the process considerably but can also lead to unwanted effects where pixels with the category to remove are mixed with pixels with different categories. Small values of neighborhood size require a large number of iterations, therefore longer processing times, but provide better results when categories are mixed.
The maximum number of iterations is limited to 999 because the name of the temporary map at each step uses three digit to identify the iteration.
To save space, maps generated at each iteration are removed as soon as they are used. It is possible to keep these maps using the k
If the user provides the name of an MPEG output file, an animation is created by combining the raster maps of each step.
The quality (1-5) parameter controls the quality of the MPEG, lower values will yield higher quality images, but with less compression (i.e. larger MPEG file size). Switching from quality=1 to quality=5 reduces the MPEG file size of about 40%, although the actual compression ratio depends on the number of frames.
The module r.out.mpeg is used to generate the MPEG file, therefore the program mpeg_encode (aka ppmtompeg) must be available.
See r.out.mpeg manual for more information.
If a name for an MPEG output file is provided but the k flag is not set, intermediate maps are kept during the process and deleted after the MPEG file has been created.
In this example, the lakes in the landuse
map in the
North Carolina sample dataset location are replaced by categories
of the surrounding pixels:
# set the region on the landuse map
# replace pixels of category 6 (water) with values of the surrounding pixels
# create a drought.mpg animation file in the current directory
r.fill.category input=landuse@PERMANENT output=landuse_dry category=6 animationfile=./drought.mpg
It removes all water pixels in 38 iterations. A drought.mpg
MPEG file containing the animation of the replacement sequence is created in the current directory.
Paolo Zatelli and Stefano Gobbi,
DICAM, University of Trento, Italy.
Last changed: $Date: 2019-06-12 18:10:36 +0100 (Wed, 12 Jun 2019) $
Available at: r.fill.category source code (history)
Main index |
Raster index |
Topics index |
Keywords index |
Graphical index |
GRASS Development Team,
GRASS GIS 7.8.2dev Reference Manual