raster.downscale {spatialEco}R Documentation

Raster Downscale

Description

Downscales a raster to a higher resolution raster using a robust regression

Usage

raster.downscale(
  x,
  y,
  scatter = FALSE,
  full.res = FALSE,
  residuals = FALSE,
  se = FALSE,
  p = 0.95,
  uncertainty = c("none", "prediction", "confidence")
)

Arguments

x

A terra SpatRaster object representing independent variable(s)

y

A terra SpatRaster object representing dependent variable

scatter

(FALSE/TRUE) Optional scatter plot

full.res

(FALSE/TRUE) Use full resolution of x (see notes)

residuals

(FALSE/TRUE) Output raster residual error raster, at same resolution as y

se

(FALSE/TRUE) Output standard error raster, using prediction or confidence interval

p

The confidence/prediction interval (default is 95%)

uncertainty

Output uncertainty raster(s) of confidence or prediction interval, at same resolution as y. Options are c("none", "prediction", "confidence")

Details

This function uses a robust regression, fit using an M-estimation with Tukey's biweight initialized by a specific S-estimator, to downscale a raster based on higher-resolution or more detailed raster data specified as covariate(s). You can optionally output residual error, standard error and/or uncertainty rasters. However, please note that when choosing the type of uncertainty, using a confidence interval (uncertainty around the mean predictions) when you should be using the prediction interval (uncertainty around a single values) will greatly underestimate the uncertainty in a given predicted value (Bruce & Bruce 2017). The full.res = TRUE option uses the x data to sample y rather than y to sample x. THis makes the problem much more computationally and memory extensive and should be used with caution. There is also the question of pseudo-replication (sample redundancy) in the dependent variable. Statistically speaking one would expect to capture the sample variation of x by sampling at the frequency of y thus supporting the downscaling estimate. Note that if uncertainty is not defined the prediction interval for standard error defaults to "confidence" else is the same output as uncertainty (eg., prediction or confidence).

Value

A list object containing:

Author(s)

Jeffrey S. Evans jeffrey_evans@tnc.org

References

Bruce, P., & A. Bruce. (2017). Practical Statistics for Data Scientists. O’Reilly Media.

Examples


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")
tmax <- worldclim_country(country="SWZ", var="tmax", path=tempdir())
  tmax <- crop(tmax[[1]], ext(elev))

# Downscale temperature
x=c(elev,slp)
  names(x) <- c("elev","slope")
y=tmax
  names(y) <- c("tmax")

tmax.ds <- raster.downscale(x, y, scatter=TRUE, residuals = TRUE,
                            uncertainty = "prediction", se = TRUE)
	
  # plot prediction and parameters	
  opar <- par(no.readonly=TRUE)
    par(mfrow=c(2,2))
      plot(tmax, main="Temp max")
      plot(x[[1]], main="elevation")
      plot(x[[2]], main="slope")
      plot(tmax.ds$downscale, main="Downscaled Temp max")
  par(opar)

  # Plot residual error and raw prediction +/- intervals
  opar <- par(no.readonly=TRUE)
    par(mfrow=c(2,2))
      plot(tmax.ds$std.error, main="Standard Error")
      plot(tmax.ds$residuals, main="residuals")
      plot(tmax.ds$uncertainty[[1]], 
	       main="lower prediction interval")
      plot(tmax.ds$uncertainty[[2]], 
	       main="upper prediction interval")
  par(opar)
  
  # plot prediction uncertainty
  opar <- par(no.readonly=TRUE)
    par(mfrow=c(2,1))
      plot(tmax.ds$downscale - tmax.ds$uncertainty[[1]], 
	       main="lower prediction interval")
      plot(tmax.ds$downscale - tmax.ds$uncertainty[[2]], 
	       main="upper prediction interval")  
  par(opar)  

} else { 
  cat("Please install geodata package to run example", "\n")
}


[Package spatialEco version 2.0-2 Index]