Blend rasters based on a provided formula

blend_rasters(x, formula, ...)

Arguments

x

A SpatRaster object with one or more layers

formula

A formula specifying how to combine the rasters

...

Additional SpatRaster objects to blend

Value

A SpatRaster object with the combined layers

Examples

rast_grid = terra::rast(ncols = 300, nrows = 100,
  xmin = 0, xmax = 300, ymin = 0, ymax = 100)

sf1 = sim_covariates(
  rast_grid,
  n = 4,
  method = simulate_gaussian(range = 25)
)

g1 = blend_rasters(sf1, ~ cov1 + cov4)
g2 = blend_rasters(g1, ~ outcome^2 + (cov2 + 2), sf1)

terra::plot(g1)

terra::plot(g2)