Learn R Programming

terra (version 1.5-21)

is.bool: Raster value types

Description

The values in a SpatRaster layer are by default numeric, but they can also be logical (Boolean), integer, or categorical

Note that as.bool and as.int return a new SpatRaster, whereas is.bool and is.int return a logical value for each layer. For a SpatRaster, isTRUE is equivalent to as.bool, isFALSE is equivalent to !as.bool, as.integer is the same as as.int and as.logical is the same as as.bool

Usage

# S4 method for SpatRaster
is.bool(x)
# S4 method for SpatRaster
as.bool(x, filename, ...)
# S4 method for SpatRaster
is.int(x)
# S4 method for SpatRaster
as.int(x, filename, ...)

Arguments

x

SpatRaster

filename

character. Output filename

...

list with named options for writing files as in writeRaster

Value

logical or SpatRaster

Examples

Run this code
# NOT RUN {
r <- rast(nrows=10, ncols=10, vals=1:100)
is.bool(r)
z <- as.bool(r)
is.bool(z)

x <- r > 25
is.bool(x)

rr <- r/2
is.int(rr)
is.int(round(rr))
# }

Run the code above in your browser using DataLab