Learn R Programming

RGISTools (version 0.9.7)

genLimitRasterRange: Limit the maximum and the minimum values of a raster

Description

genLimitRasterRange limits the maximum and the minimum values of a Raster* class object to a given range.

Usage

genLimitRasterRange(r, mx = NULL, mn = NULL, rm.values = FALSE)

Arguments

r

Raster* type object.

mx

maximun value in the Raster*.

mn

minimun value in the Raster*.

rm.values

logical argument. If FALSE, the mx and mn values are assigned to the pixels above or below the mx and mn thresholds respectively. If TRUE, values outside the mn - mx range are replaced by NA.

Value

a Raster* with values comprised within a range.

Details

This is a generic function to limit the maximun and the minimun values in a Raster* object.

Examples

Run this code
# NOT RUN {
# generate random images
img <- matrix(1:16, ncol = 4, byrow = TRUE)
r <- raster(img)
# assign the limit of the data in the raster stack
r2 <- genLimitRasterRange(r, mn = 4, mx = 10)
r3 <- genLimitRasterRange(r, mn = 4, mx = 10, rm.values = TRUE)
# plot limited data
spplot(stack(r, r2 ,r3))
# }

Run the code above in your browser using DataLab