Skip to contents

Generating random environmental layers

Usage

generate_env_layer(
  seed = 2,
  grid,
  n = 2,
  beta = 1,
  norm = TRUE,
  return_rasters = TRUE
)

Arguments

seed

Value to feed set.seed (default 2)

grid

Grid of the virtual space, as generated by create_grid

n

Number of layers to be generated (default 2)

beta

The beta value to be forwarded to gstat (default to 1)

norm

Should the resulting layers be normalized?

return_rasters

Should the function returns SpatRast in addition to data frame?

Value

Returns a data frame with the simulated environmental values, as well as SpatRast is return_rasters = TRUE

See also

Other environment simulation functions: generate_resource_layer()

Examples

grid <- create_grid()

str(generate_env_layer(norm = FALSE, return_rasters = FALSE, grid = grid))
#> [using unconditional Gaussian simulation]
#> 'data.frame':	32761 obs. of  4 variables:
#>  $ x   : num  0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 ...
#>  $ y   : num  0 0 0 0 0 0 0 0 0 0 ...
#>  $ sim1: num  4.7 5.35 4.82 7.42 6.74 ...
#>  $ sim2: num  -0.381 -0.575 -0.766 -3.876 -4.276 ...

library(terra)
#> terra 1.7.78
plot(generate_env_layer(norm = TRUE, return_rasters = TRUE, grid = grid)$rasters)
#> [using unconditional Gaussian simulation]