Blend rasters based on a provided formula

blend_rasters(r, formula, ...)

Arguments

r

A SpatRaster object with one or more layers

formula

A formula that specifies 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, range = 25,
  vgm = gstat::vgm(model = "Exp", psill = 1, range = 10), n = 4)
g1 = blend_rasters(sf1, y ~ cov1 + cov4)
g2 = blend_rasters(g1, y ~ outcome^2 + (cov2 + 2), sf1)
terra::plot(g1)

terra::plot(g2)