View source: R/aspline.downscale.R
aspline.downscale | R Documentation |
Downscales a raster to a higher resolution raster multivariate adaptive regression splines (MARS).
aspline.downscale(
x,
y,
add.coords = TRUE,
keep.model = FALSE,
grid.search = FALSE,
plot = FALSE,
...
)
x |
A terra SpatRaster object representing independent variable(s) |
y |
A terra SpatRaster object representing dependent variable |
add.coords |
(FALSE/TRUE) Add spatial coordinates to model |
keep.model |
(FALSE/TRUE) Keep MARS model (earth class object) |
grid.search |
(FALSE/TRUE) perform a hyper-parameter grid se |
plot |
(FALSE/TRUE) Plot results |
... |
Additional arguments passed to earth |
This function uses Multivariate Adaptive Regression Splines, to downscale a raster based on higher-resolution or more detailed raster data specified as covariate(s). This is similar to the raster.downsample function which uses a robust regression and is a frequentest model for fitting linear asymptotic relationships whereas, this approach is for fitting nonparametric functions and should be used when the distributional relationship are complex/nonlinear. Using add.coords adds spatial coordinates to the model, including creating the associated rasters for prediction.
A list object containing:
downscale Downscaled terra SpatRaster object
GCV Generalized Cross Validation (GCV)
GRSq Estimate of the predictive power
RSS Residual sum-of-squares (RSS)
RSq R-square
model earth MARS model object (if keep.model = TRUE)
Jeffrey S. Evans jeffrey_evans@tnc.org
Friedman (1991) Multivariate Adaptive Regression Splines (with discussion) Annals of Statistics 19(1):1–141
if (require(geodata, quietly = TRUE)) {
library(terra)
library(geodata)
# Download example data (requires geodata package)
elev <- elevation_30s(country="SWZ", path=tempdir())
slp <- terrain(elev, v="slope")
x <- c(elev,slp)
names(x) <- c("elev","slope")
tmax <- worldclim_country(country="SWZ", var="tmax",
path=tempdir())
tmax <- crop(tmax[[1]], ext(elev))
names(tmax) <- "tmax"
tmax.ds <- aspline.downscale(x, tmax, add.coords=TRUE, keep.model=TRUE)
plot(tmax.ds$model)
# plot prediction and parameters
opar <- par(no.readonly=TRUE)
par(mfrow=c(2,2))
plot(tmax, main="Original Temp max")
plot(x[[1]], main="elevation")
plot(x[[2]], main="slope")
plot(tmax.ds$downscale, main="Downscaled Temp max")
par(opar)
} else {
cat("Please install geodata package to run example", "\n")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.