Generic function for simulating spatial covariates using a specified method.

sim_covariates(rast_grid, n = 6, method)

Arguments

rast_grid

A SpatRaster object with the desired dimensions

n

The number of covariates to simulate (must be >= 1)

method

A simulation factory function —- call the function with parameters to create the method (remember to not pass the function itself). For example: method = simulate_gaussian(range = 25), not method = simulate_gaussian. See simulate_gaussian() and simulate_random() for examples.

Value

A SpatRaster with n layers named cov1, cov2, ..., covN

Examples

rast_grid = terra::rast(ncols = 300, nrows = 100,
  xmin = 0, xmax = 300, ymin = 0, ymax = 100)
# Gaussian simulation
sf1 = sim_covariates(rast_grid, n = 4, method = simulate_gaussian(range = 25))
sf2 = sim_covariates(rast_grid, n = 4, method = simulate_gaussian(range = 50, model = "Exp"))
# Reusable simulation engine
gauss = simulate_gaussian(range = 25)
sf3 = sim_covariates(rast_grid, n = 4, method = gauss)
# Random simulation
sf4 = sim_covariates(rast_grid, n = 4, method = simulate_random())
terra::plot(sf1)

terra::plot(sf2)

terra::plot(sf3)

terra::plot(sf4)