Learn R Programming

raster (version 2.3-40)

clamp: Clamp values

Description

Clamp values to a mininum and maximum value. That is, all values below the lower clamp value and the upper clamp value become NA (or the lower/upper value if useValue=TRUE)

Usage

## S3 method for class 'Raster':
clamp(x, lower=-Inf, upper=Inf, useValues=TRUE, filename="", ...)

Arguments

x
RasterLayer
lower
numeric. lowest value
upper
numeric. highest value
useValues
logical. If FALSE values outside the clamping range become NA, if TRUE, they get the extreme values
filename
character. Filename for the output RasterLayer (optional)
...
additional arguments as for writeRaster

Value

  • Raster object

See Also

reclassify

Examples

Run this code
r <- raster(ncols=12, nrows=12)
values(r) <- 1:ncell(r)
rc <- clamp(r, 25, 75) 
rc

Run the code above in your browser using DataLab