Skip to contents

Difference between raster objects

Usage

differ.rast(r1, r2, perc = TRUE, filename = "")

Arguments

r1

A SpatRaster object.

r2

A SpatRaster object.

perc

Boolean. Default is TRUE to calculate the percentage of change between r1 and r2. FALSE gives the absolute number instead.

filename

Character. Save results if a name is provided.

Value

A SpatRaster object with the difference between r1 and r2.

Examples

# \donttest{
library(terra)
rich1 <- terra::rast(system.file("extdata", "rich_ref.tif",
package = "divraster"))
rich2 <- terra::rast(system.file("extdata", "rich_fut.tif",
package = "divraster"))
differ.rast(rich1, rich2)
#> class       : SpatRaster 
#> dimensions  : 8, 8, 1  (nrow, ncol, nlyr)
#> resolution  : 0.125, 0.125  (x, y)
#> extent      : 0, 1, 0, 1  (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326) 
#> source(s)   : memory
#> varname     : rich_fut 
#> name        : Percentage Difference 
#> min value   :             -71.42857 
#> max value   :             200.00000 
# }