cat_to_val {rasterDT} | R Documentation |
Convert a Categorical Raster to a Value Raster
Description
Use a categorical raster's RAT to convert it to a continuous raster
Usage
cat_to_val(r, which = 2)
Arguments
r |
A categorical raster with a RAT (returned by
|
which |
An integer or character string giving the index or
name of the column in |
Value
A continuous raster with each category level in r
replaced by its corresponding value.
Author(s)
Joshua O'Brien
Examples
r_cat <- raster(matrix(c(2, 2, 2, 1), ncol = 2))
levels(r_cat) <- data.frame(ID = c(1, 2),
VAL1 = c(0.1, 200),
VAL2 = c(33, 44))
## Second column of RAT is used by default
r_con1 <- cat_to_val(r_cat)
as.matrix(r_con1)
## Use 'which=' argument for conversion to another RAT column
r_con2 <- cat_to_val(r_cat, which = "VAL2")
as.matrix(r_con2)
[Package rasterDT version 0.3.2 Index]