Skip to contents

Focal raster smooth with a median

Usage

hsi_smooth_median(
  x,
  window = 3,
  cores = 1L,
  filename = "",
  overwrite = FALSE,
  ...
)

Arguments

x

A SpatRaster with hyperspectral data.

window

Positive odd integer. Focal window size. Default 3.

cores

Positive integer. Number of cores for parallel processing. Default 1L (single core). Passed to terra::focal().

filename

Character. Output filename. Default "" keeps result in memory.

overwrite

Logical. Overwrite existing file. Default FALSE.

...

Additional arguments passed to terra::writeRaster().

Value

A SpatRaster with median filtered values.

Examples

if (FALSE) { # \dontrun{
x <- terra::rast("REFLECTANCE_testdata.tif")

x_smooth_median <- hsi_smooth_median(x)

x_smooth_median <- hsi_smooth_median(
  x,
  filename = "output_median.tif",
  overwrite = TRUE
)
} # }