This function transforms selected subset of abundance matrices from
sim_results
into SpatRaster
object. Layers are
specified by time_points
that can be one point in time or many.
Arguments
- sim_results
sim_results
object created bysim
- time_points
numeric vector of length 1 or more; specifies points in time from which
SpatRaster
will be createdas default the last year of simulation; if
length(time_points) > 0
SpatRaster
will be returned with layers for each element oftime_points
- template
SpatRaster
object; can be used as template to create returned object
Value
SpatRaster
based on sim_results
object
with layers corresponding to time_points
Examples
if (FALSE) {
# data preparation
library(terra)
n1_small <- rast(system.file("input_maps/n1_small.tif", package = "rangr"))
K_small <- rast(system.file("input_maps/K_small.tif", package = "rangr"))
sim_data <- initialise(
n1_map = n1_small,
K_map = K_small,
r = log(2),
rate = 1 / 1e3
)
# simulation
sim_1 <- sim(obj = sim_data, time = 100)
# raster construction
my_rast <- to_rast(
sim_1,
time_points = c(1, 10, 20, 100),
template = sim_data$K_map
)
# visualization
plot(my_rast, range = range(sim_1$N_map, na.rm = TRUE))
}