Logic-methods

0th

Percentile

Logical operators and functions

The following logical (boolean) operators are available for computations with RasterLayer objects:

&, |, and !

The following functions are available with a Raster* argument:

is.na, is.nan, is.finite, is.infinite

Keywords
methods, math
Value

A Raster object with logical (TRUE/FALSE values)

Note

These are convenient operators/functions that are most usful for relatively small RasterLayers for which all the values can be held in memory. If the values of the output RasterLayer cannot be held in memory, they will be saved to a temporary file. In that case it could be more efficient to use calc instead.

See Also

Math-methods, overlay, calc

Aliases
  • Logic-methods
  • Logic,Raster,Raster-method
  • is.na,Raster-method
  • is.nan,Raster-method
  • is.finite,Raster-method
  • is.infinite,Raster-method
  • !,Raster-method
Examples
# NOT RUN {
r <- raster(ncols=10, nrows=10)
r[] <- runif(ncell(r)) * 10
r1 <- r < 3 | r > 6
r2 <- !r1
r3 <- r >= 3 & r <= 6
r4 <- r2 == r3
r[r>3] <- NA
r5 <- is.na(r)
r[1:5]
r1[1:5]
r2[1:5]
r3[1:5]

# }
Documentation reproduced from package raster, version 2.9-5, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.