subs
and cut
are more efficient.
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.
reclass(x, rcl, ...)
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. "text", "window", or "" (the default, no progress bar)
}subs, cut, calc
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