raster (version 1.1.7)

reclass: Reclassify

Description

Reclassify values of a RasterLayer. 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". Reclassification is applied to from <= x="" <="to. Unless update=TRUE Reclassification is done in the order of the reclass table. Thus there are overlapping ranges, the last range applies.

Usage

reclass(x, rcl, ...)

Arguments

x
A RasterLayer object
rcl
Matrix (or vector) 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 coecred into a n*3 matrix
...
additional arguments. See Details.

Value

  • A new RasterLayer object, and in some cases the side effect of a new file on disk.

Details

The following additional arguments can be passed, to replace default values for this function rll{ update Logical. If update=TRUE, reclass can update values that were classified according to an earlier row in the reclass table. For example if row 1 has 1, 10, 15 and row 2 has 11, 20, 25, all the values from 1 to 20 will be classified as 25. 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. Valid values are "text", "tcltk", "windows" (on that platform only) and "" }

See Also

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 DataCamp Workspace