Arithmic with rasters

Standard arithmic operators for computations with RasterLayer objects and numeric values. The following operators are available: +, -, *, /, ^, %%, %/% Operators are applied on a cell by cell basis, and single numeric values are recycled. Input RasterLayers must have the same extent and resolution.

methods, spatial, math

If the values of the output RasterLayer cannot be held in memory, they will be saved to a temporary file unless a default filename has been set with rasterOptions. You can also use rasterOptions to set the format, datatype and overwrite options.


  • A RasterLayer object, and in some cases the side effect of a new file on disk.

See Also

Math-methods, overlay, calc

  • Arith-methods
  • Arith,numeric,RasterLayer-method
  • Arith,RasterLayer,numeric-method
  • Arith,RasterLayer,RasterLayer-method
r1 <- raster(ncols=10, nrows=10)
r1[] <- runif(ncell(r1))
r2 <- setValues(r1, 1:ncell(r1) / ncell(r1) )
r3 <- r1 + r2
r2 <- r1 / 10
r3 <- r1 * (r2 - 1 + r1^2 / r2)
Documentation reproduced from package raster, version 1.0.0-1, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.