raster (version 1.1.7)

Arith-methods: Arithmic with rasters

Description

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.

Arguments

Value

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

Details

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.

See Also

Math-methods, overlay, calc

Examples

Run this code
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)

Run the code above in your browser using DataCamp Workspace