A user will likely already have environmental data organized into a list of 'spatRaster' stacks where each element is a different environmental variable and each layer corresponds to a depth slice for background sampling and extracting. However, the maxent_3D function requires the data be input as a list of 'spatRaster' stacks where each element corresponds to a depth slice and each layer is an environmental variable for the purpose of projecting the model back into geographic space, and this function has been developed for ease of conversion.

env_stack_transform(envs_all, envs_names)

Arguments

envs_all

a list of 'spatRaster' stacks where each element is a different environmental variable and each layer is a depth slice.

envs_names

A 'character' vector of the names of the environmental variables to be applied to the layers of the resulting list of 'spatRaster' stacks

Value

A list of 'spatRaster' stacks where each list element is a depth slice and each layer is an environmental variable.

Details

The extents of each environmental variable layer should match on a depth slice by depth slice basis.

Examples

library(terra)

# creating a list of spatRaster stacks where each element is an environmental variable
# and each layer is a depth

env1_d1 <- rast(ncol = 50, nrow = 50)
values(env1_d1) <- sample(c(1:100), size = 2500, replace = TRUE)
env2_d1 <- rast(ncol = 50, nrow = 50)
values(env2_d1) <- sample(c(1:100), size = 2500, replace = TRUE)
env1_d2 <- rast(ncol = 50, nrow = 50)
values(env1_d2) <- sample(c(1:100), size = 2500, replace = TRUE)
env2_d2 <- rast(ncol = 50, nrow = 50)
values(env2_d2) <- sample(c(1:100), size = 2500, replace = TRUE)

env1 <- c(env1_d1, env1_d2)
env2 <- c(env2_d1, env2_d2)
envs <- list(env1, env2)
envnames <- c("env1", "env2")

# Here's the function
result <- env_stack_transform(envs_all = envs, envs_names = envnames)