reduce | R Documentation |
Reduce the number of layers by either performing a PCA on them or by eliminating highly correlated ones.
reduce(layers, method = "pca", n = NULL, thres = NULL)
layers |
SpatRaster. As defined in package terra, see |
method |
character. Either Principal Components Analysis ("pca", default) or Pearson's correlation ("cor"). |
n |
numeric. Number of layers to reduce to. |
thres |
numeric. Value for pairwise Pearson's correlation above which one of the layers (randomly selected) is eliminated. |
Using a large number of explanatory variables in models with few records may lead to overfitting. This function allows to avoid it as much as possible. If both n and thres are given, n has priority. If method is not recognized and layers come from read function, only landcover is reduced by using only the dominating landuse of each cell.
SpatRaster.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.