Skip to contents

This function linearly interpolates values in a series of carrying capacity maps.

Usage

K_get_interpolation(K_map, K_time_points = NULL, time = NULL)

Arguments

K_map

SpatRaster object with carrying capacity maps for each K_time_points

K_time_points

integer vector; time for each layer in K_map

time

integer vector of length 1; number of total time steps required (this is defined when evoking the function sim).

Value

SpatRaster object with number of layers equal to time

Details

To simulate dynamic environmental scenarios (i.e. climate change, land use change, ecological disturbance, etc.) one needs to provide time-varying carrying capacity maps.

Either K_time_points or time parameter are needed to calculate interpolation. If interpolation should be calculated between two carrying capacity maps, there is no need to pass the time points, because 1 will be set as a starting time point and time will be used as the ending point. On the other hand, in the absence of the time argument, the last element of K_time_points is considered to be the ending point for the interpolation.

Examples

if (FALSE) {

# data preparation
library(terra)

n1_small <- rast(system.file("input_maps/n1_small.tif", package = "rangr"))
K_small_changing <- rast(system.file("input_maps/K_small_changing.tif",
package = "rangr"))

K_interpolated_01 <- K_get_interpolation(
  K_small_changing,
  K_time_points = c(1, 10, 15)
)

K_two_layers <- subset(
  K_small_changing,
  c(1, 2)
)
K_interpolated_02 <- K_get_interpolation(
  K_two_layers,
  time = 15
)

}