denoise,GRaster-method | R Documentation |
denoise()
applies a principal component analysis (PCA) to layers of a GRaster
, then uses the PCA to predict values back to a raster. This retains only coarse-scale trends, thereby removing "noise" (locally extreme values that fall far from a PC axis).
noise()
does the opposite by first constructing the PCA, predicting values back to the raster, then subtracting these values from the original, removing coarse-scale trends and thereby leaving "noise".
## S4 method for signature 'GRaster'
denoise(x, scale = FALSE, percent = 80)
## S4 method for signature 'GRaster'
noise(x, scale = FALSE, percent = 80)
x |
A |
scale |
Logical: If |
percent |
Numeric integer or integer in the range 50 to 99 (default is 80): Minimum total variation explained in the retained PC axes. Higher values will cause |
A multi-layer GRaster
with one layer per input.
princomp()
, stats::prcomp()
, GRASS manual page for module i.pca
(see grassHelp("i.pca")
)
if (grassStarted()) {
# Setup
library(terra)
# Climate raster:
madChelsa <- fastData("madChelsa")
# Convert a SpatRaster to a GRaster:
chelsa <- fast(madChelsa)
### Denoise:
quiet <- denoise(chelsa, scale = TRUE)
compare1 <- c(chelsa[["bio1"]], quiet[["bio1"]])
plot(compare1)
compare2 <- c(chelsa[["bio7"]], quiet[["bio7"]])
plot(compare2)
### Noise:
loud <- noise(chelsa, scale = TRUE)
compare1 <- c(chelsa[["bio1"]], loud[["bio1"]])
plot(compare1)
compare2 <- c(chelsa[["bio7"]], loud[["bio7"]])
plot(compare2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.