GRASS logo

NAME

r.fill.category - Replaces the values of pixels of a given category with values of the surrounding pixels.

KEYWORDS

raster, algebra, category

SYNOPSIS

r.fill.category
r.fill.category --help
r.fill.category [-k] input=name output=name category=integer [nsize=integer] [maxiter=integer] [animationfile=name] [quality=integer] [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags:

-k
Keep intermediate maps
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

input=name [required]
Name of input raster map
output=name [required]
Name for output raster map
category=integer [required]
Category to replace
nsize=integer
Neighborhood size in pixel
Default: 19
maxiter=integer
Maximum number of iterations
Options: 1-999
Default: 100
animationfile=name
Name for animation output file
quality=integer
Quality factor for animation (1 = highest quality, lowest compression)
Options: 1-5
Default: 3

Table of contents

DESCRIPTION

r.fill.category 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.

PARAMETERS

The user controls the process by setting the neighborhood size in pixels and the maximum number of iterations.

The neighborhood size (nsize) 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 (maxiter) is limited to 999 because the name of the temporary map at each step uses three digits to identify the iteration.

INTERMEDIATE MAPS

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 flag.

ANIMATION

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.

EXAMPLE

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
g.region rast=landuse@PERMANENT
# 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.

SEE ALSO

r.neighbors, r.reclass.area, r.out.mpeg, r.fill.gaps

AUTHORS

Paolo Zatelli and Stefano Gobbi, DICAM, University of Trento, Italy.

SOURCE CODE

Available at: r.fill.category source code (history)

Latest change: Monday Jan 30 19:52:26 2023 in commit: cac8d9d848299297977d1315b7e90cc3f7698730


Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

© 2003-2024 GRASS Development Team, GRASS GIS 8.4.1dev Reference Manual