Learn R Programming

raster (version 1.8-3)

which: Which cells are TRUE?

Description

Which returns a RasterLayer with TRUE or FALSE. Cells with 1 are set to TRUE, all other cells, including NA are set to FALSE

Usage

Which(x, ...)

Arguments

x
A RasterLayer object or a logical expression resulting in a RasterLayer object
...
Additional arguments. See Details

Value

  • a RasterLayer object

Details

You can use the additional logical argument cells. If cells=FALSE (the default), a (logical) RasterLayer is returned, if cells=TRUE, the cell numbers are returned for which the condition is TRUE

See Also

which

Examples

Run this code
r <- raster(ncol=10, nrow=10)
r[] <- runif(ncell(r))
r[r< 0.2] <- NA
s <- Which(r > 0.5, cells=TRUE)
s[1:5]
s <- Which(r > 0.5)

Run the code above in your browser using DataLab