# \donttest{
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")
}
# }
Run the code above in your browser using DataLab