This function takes a rasterstack of pathdistances and generates surfaces by weighting parameter values by these distances

ipdwInterp(
  sf_ob,
  rstack,
  paramlist,
  overlapped = FALSE,
  yearmon = "default",
  removefile = TRUE,
  dist_power = 1,
  trim_rstack = FALSE
)

Arguments

sf_ob

sf object with point geometries

rstack

RasterStack of path distances

paramlist

character. String representing parameter names

overlapped

logical. Default is FALSE, specify TRUE if some points lie on top of barriers

yearmon

character. String specifying the name of the sf object

removefile

logical. Remove files after processing?

dist_power

numeric. Distance decay power (p)

trim_rstack

logical. Trim the raster stack by the convex hull of sf_ob

Value

RasterLayer

Details

Under the hood, this function evaluates: $$V = \frac{\sum\limits_{i=1}^n v_i \frac{1}{d_i^p}}{\sum\limits_{i=1}^n \frac{1}{d_i^p}}$$ where d is the distance between prediction and measurement points, v_i is the measured parameter value, and p is a power parameter.

Examples

library(sf)
sf_ob <- data.frame(rnorm(2))
xy    <- data.frame(x = c(4, 2), y = c(8, 4))
sf_ob <- st_as_sf(cbind(sf_ob, xy), coords = c("x", "y"))

m <- matrix(NA, 10, 10)
costras <- raster(m, xmn = 0, xmx = ncol(m), ymn = 0, ymx = nrow(m))

# introduce spatial gradient
costras[] <- runif(ncell(costras), min = 1, max = 10)
for (i in 1:nrow(costras)) {
  costras[i, ] <- costras[i, ] + i
  costras[, i] <- costras[, i] + i
}

rstack <- pathdistGen(sf_ob, costras, 100, progressbar = FALSE)
final.raster <- ipdwInterp(sf_ob, rstack, paramlist = c("rnorm.2."), overlapped = TRUE)
plot(final.raster)
plot(sf_ob, add = TRUE)