Learn R Programming

raster (version 1.9-27)

reclass: Reclassify

Description

Reclassify values of a Raster* object. The function (re)classifies groups of values to other values. E.g. All values between 1 and 10 become 1, and all values between 11 and 15 become 2. Reclassification is done with matrix "rcl". For simple cases, the functions subs and cut may be more efficient. Reclassification is done in the order of the reclass table. Thus, if there are overlapping ranges, the last range applies.

Usage

reclass(x, rcl, ...)

Arguments

x
A Raster* object
rcl
Matrix for reclassifcation. This matrix must have 3 columns. The first two columns are "from" "to" of the input values, and the third column has the new value for that range. (You can also supply a vector that can be coerced into a n*3 matrix (with byrow=
...
additional arguments. See Details.

Value

  • Raster* object

Details

The following additional arguments can be passed, to replace default values for this function rll{ include.lowest logical, indicating if a value equal to the lowest value in rcl (or highest value in the second column, for right = FALSE) should be included. The default is FALSE right logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa. The default is TRUE } You can also use these additional arguments to save the result to a file rll{ filename Output filename (can be absent for RasterLayers that can be stored in memory) format Character. Output file type. See writeRaster datatype Character. Output data type; can be 'INT', 'FLT', or a complete datatype description, see dataType overwrite Logical. If TRUE, "filename" will be overwritten if it exists progress Character. "text", "window", or "" (the default, no progress bar) }

See Also

subs, cut, calc

Examples

Run this code
r <- raster(ncols=36, nrows=18)
r[] <- runif(ncell(r)) 
# reclassify the values into three groups 
# all values >= 0 and <= 0.25 become 1, etc.
m <- c(0, 0.25, 1,  0.25, 0.5, 2,  0.5, 1, 3)
rclmat <- matrix(m, ncol=3, byrow=TRUE)
rc <- reclass(r, rclmat)

# equivalent to
rc <- reclass(r, c(-Inf,0.25,1, 0.25,0.5,2, 0.5,Inf,3))

Run the code above in your browser using DataLab