subs
and cut
for alternative approaches).
Reclassification is done with matrix rcl
, in the row order of the reclassify table. Thus, if there are overlapping ranges, the first time a number is within a range determines the reclassification value.## S3 method for class 'Raster':
reclassify(x, rcl, filename='', include.lowest=FALSE, right=TRUE, ...)
FALSE
TRUE
. A special case is to use right=NA. In this case both the left and right intervals are openwriteRaster
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 <- reclassify(r, rclmat)
# equivalent to
rc <- reclassify(r, c(-Inf,0.25,1, 0.25,0.5,2, 0.5,Inf,3))
Run the code above in your browser using DataLab