Apply a sieve filter. That is, remove "noise", by changing small clumps of cells with a value that is different from the surrounding cells, to the value of the largest neighboring clump.
Note that the numerical input values are truncated to integers.
Usage
# S4 method for SpatRaster
sieve(x, threshold, directions=8, filename="", ...)
Arguments
x
SpatRaster, single layer with integer or categorical values
threshold
positive integer. Only clumps smaller than this threshold will be removed
directions
numeric to indicate which cells are connected. Either 4 to only consider the horizontal and vertical neighbors ("rook"), or 8 to consider the vertical, horizontal and diagonal neighbors