Learn R Programming

terra (version 1.7-83)

identical: Compare two SpatRasters for equality

Description

Compare two SpatRasters for equality.

First the attributes of the objects are compared. If these are the same, a the raster cells are compared as well. This can be time consuming, and you may prefer to use a sample instead with all.equal

Usage

# S4 method for SpatRaster,SpatRaster
identical(x, y)

Value

single logical value

Arguments

x

SpatRaster

y

SpatRaster

See Also

all.equal, compareGeom

Examples

Run this code
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 = t(mat))

identical(r1, r2)
identical(r1, r1*1)
identical(rast(r1), rast(r2))

Run the code above in your browser using DataLab