Compare-methods

0th

Percentile

Compare Raster* objects

These methods compare the location and resolution of Raster* objects. That is, they compare their spatial extent, projection, and number of rows and columns.

For BasicRaster objects you can use == and !=, the values returned is a single logical value TRUE or FALSE

For RasterLayer objects, these operators also compare the values associated with the objects, and the result is a RasterLayer object with logical (Boolean) values.

The following methods have been implemented for RasterLayer objects:

==, !=, >, <, <=, >=

Keywords
methods, math
Value

A logical value or a RasterLayer object, and in some cases the side effect of a new file on disk.

Aliases
  • Compare-methods
  • Compare,Extent,Extent-method
  • Compare,Raster,Raster-method
  • Compare,Raster,logical-method
  • Compare,Raster,numeric-method
  • Compare,logical,Raster-method
  • Compare,numeric,Raster-method
  • ==,BasicRaster,BasicRaster-method
  • !=,BasicRaster,BasicRaster-method
Examples
# NOT RUN {
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 
# that do not have the same BasicRaster properties.
#r3 <- r1 > r4
# }
Documentation reproduced from package raster, version 2.9-5, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.