Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

compare

Compare Raster objects


Description

Evaluate whether a two or more Raster* objects have the same extent, number of rows and columns, projection, resolution, and origin (or a subset of these comparisons).

all.equal is a wrapper around compareRaster with options values=TRUE, stopiffalse=FALSE and showwarning=TRUE.

Usage

compareRaster(x, ..., extent=TRUE, rowcol=TRUE, crs=TRUE, res=FALSE, orig=FALSE,
         rotation=TRUE, values=FALSE, tolerance, stopiffalse=TRUE, showwarning=FALSE)

Arguments

x

Raster* object

...

Raster* objects

extent

logical. If TRUE, bounding boxes are compared

rowcol

logical. If TRUE, number of rows and columns of the objects are compared

crs

logical. If TRUE, coordinate reference systems are compared.

res

logical. If TRUE, resolutions are compared (redundant when checking extent and rowcol)

orig

logical. If TRUE, origins are compared

rotation

logical. If TRUE, rotations are compared

values

logical. If TRUE, cell values are compared

tolerance

numeric between 0 and 0.5. If not supplied, the default value is used (see rasterOptions. It sets difference (relative to the cell resolution) that is permissible for objects to be considered 'equal', if they have a non-integer origin or resolution. See all.equal.

stopiffalse

logical. If TRUE, an error will occur if the objects are not the same

showwarning

logical. If TRUE, an warning will be given if objects are not the same. Only relevant when stopiffalse is TRUE

Examples

r1 <- raster()
r2 <- r1
r3 <- r1
compareRaster(r1, r2, r3)
nrow(r3) <- 10

# compareRaster(r1, r3)
compareRaster(r1, r3, stopiffalse=FALSE)
compareRaster(r1, r3, rowcol=FALSE)

all.equal(r1, r2)
all.equal(r1, r3)

raster

Geographic Data Analysis and Modeling

v3.4-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Jacob van Etten [ctb], Michael Sumner [ctb], Joe Cheng [ctb], Dan Baston [ctb], Andrew Bevan [ctb], Roger Bivand [ctb], Lorenzo Busetto [ctb], Mort Canty [ctb], Ben Fasoli [ctb], David Forrest [ctb], Aniruddha Ghosh [ctb], Duncan Golicher [ctb], Josh Gray [ctb], Jonathan A. Greenberg [ctb], Paul Hiemstra [ctb], Kassel Hingee [ctb], Institute for Mathematics Applied Geosciences [cph], Charles Karney [ctb], Matteo Mattiuzzi [ctb], Steven Mosher [ctb], Babak Naimi [ctb], Jakub Nowosad [ctb], Edzer Pebesma [ctb], Oscar Perpinan Lamigueiro [ctb], Etienne B. Racine [ctb], Barry Rowlingson [ctb], Ashton Shortridge [ctb], Bill Venables [ctb], Rafael Wueest [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.