# all.equal: Compare two SpatRasters for equality In terra: Spatial Data Analysis

## Description

Compare two SpatRasters for (near) equality.

First the attributes of the objects are compared. If these are the same, a (perhaps small) sample of the raster cells is compared as well.

The sample size used can be increased with the `maxcell` argument. You can set it to `Inf`, but for large rasters your computer may not have sufficient memory. See the examples for a safe way to compare all values.

## Usage

 ```1 2``` ```## S4 method for signature 'SpatRaster,SpatRaster' all.equal(target, current, maxcell=10000, ...) ```

## Arguments

 `target` SpatRaster `current` SpatRaster `maxcell` postive integer. The size of the regular sample used to compare cell values `...` additional arguments passed to all.equal.numeric to compare cell values

## Value

Either `TRUE` or a chracter vector describing the differences between target and current.

## See Also

`compareGeom`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19``` ```x <- sqrt(1:100) mat <- matrix(x, 10, 10) r1 <- rast(nrows=10, ncols=10, xmin=0, vals = x) r2 <- rast(nrows=10, ncols=10, xmin=0, vals = mat) all.equal(r1, r2) all.equal(r1, r1*1) all.equal(rast(r1), rast(r2)) # compare geometries compareGeom(r1, r2) # Compare all cell values for near equality # as floating point number imprecision can be a problem m <- minmax(r1 - r2) all(abs(m) < 1e-7) # comparison of cell values to create new SpatRaster e <- r1 == r2 ```

terra documentation built on Jan. 13, 2022, 5:08 p.m.