to_rast | R Documentation |
sim_results
To RasterThis function transforms selected subset of abundance matrices from
sim_results
into SpatRaster
object. Layers are
specified by time_points
, which can be one or multiple points in time.
to_rast(sim_results, time_points = sim_results$simulated_time, template = NULL)
sim_results |
|
time_points |
numeric vector of length 1 or more; specifies points in
time from which |
template |
|
SpatRaster
based on sim_results
object
with layers corresponding to time_points
.
Hijmans R (2024). terra: Spatial Data Analysis. R package version 1.7-81, https://rspatial.github.io/terra/, https://rspatial.org/
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.