replacement function

Replace cell values or layers of a Raster* object

Replace cell values or layers of a Raster* object

You can set values of a Raster* object, when i is a vector of cell numbers, a Raster*, Extent, or Spatial* object.

These are shorthand methods that work best for relatively small Raster* objects. In other cases you can use functions such as calc and rasterize. methods

Methods

See Also

calc , rasterize

Examples

r <- raster(ncol=10, nrow=5) values(r) <- 1:ncell(r) * 2 r[1,] <- 1 r[,1] <- 2 r[1,1] <- 3 s <- stack(r, sqrt(r)) s[s<5] <- NA
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2025-03-28

Downloads (last 30 days):