Converts simulated population abundance data from a sim_com_results object
(produced by sim_com()) into SpatRaster objects.
Arguments
- obj
An object of class
sim_com_results, returned bysim_com().- species
Integer vector. Species ID(s) to extract.
- time_points
Integer vector. Time step(s) to extract (excluding burn-in).
- ...
Currently unused.
Value
If
length(time_points) == 1, returns aSpatRasterwith species as layers.If
length(time_points) > 1, returns a named list ofSpatRasterobjects, one per species.If only one species is selected with multiple time points, returns a single
SpatRaster.
Examples
# Read simulation data from the mrangr package
simulated_com <- get_simulated_com()
# Extract one timestep, all species
r1 <- to_rast(simulated_com, time_points = 10)
# Extract multiple timesteps, one species
r2 <- to_rast(simulated_com, species = 2, time_points = c(1, 5, 10))
# Extract multiple timesteps, multiple species
r3 <- to_rast(simulated_com, species = c(1, 2), time_points = c(1, 5, 10))