BasicRaster
objects you can use ==
and !=
, the values returned is a single logical value TRUE
or FALSE
For RasterLayer objects, they also compare the values associated with the objects, and the result is a logical (Boolean) RasterLayer object. And the value returned is a RasterLayer object, if the location and resolution of the two RasterLayers match, or an error of they do not match.
The following methods have been implemented for RasterLayer objects:
==, !=, >, <, <=",">=
link[raster]{rasterOptions}
. You can also use link[raster]{rasterOptions}
to set the format, datatype and overwrite options.r1 <- raster()
r1 <- setValues(r1, round(10 * runif(ncell(r1))))
r2 <- setValues(r1, round(10 * runif(ncell(r1))))
as(r1, 'BasicRaster') == as(r2, 'BasicRaster')
r3 <- r1 == r2
b <- extent(0, 360, 0, 180)
r4 <- setExtent(r2, b)
as(r2, 'BasicRaster') != as(r4, 'BasicRaster')
# The following would give an error. You cannot compare RasterLayer object that do not have the same BasicRaster properties.
#r3 <- r1 > r4
Run the code above in your browser using DataLab