raster (version 1.1.7)

hist: Histogram

Description

Create a histogram of the values of a RasterLayer. NA values are ignored. Large datasets are sampled using maxpixels.

Usage

hist(x, ...)

Arguments

x
A Raster* object
...
Additional arguments. See under Methods and at hist

Value

  • This function is principally used for the side-effect of plotting a histogram, but it also returns an S3 object of class 'histogram' (invisibly if plot=TRUE).

Methods

A full call as implemented here: hist(x, layer, maxpixels=100000, plot=TRUE, main, ...) layer can be used to subset the layers to plot in a multilayer object (RasterBrick or RasterStack) maxpixels is the maximum number of (randomly sampled) cells to be used for creating the histogram see hist for the other arguments

See Also

plot and hist

Examples

Run this code
r1 <- raster(nrows=50, ncols=50)
r1 <- setValues(r1, runif(ncell(r1)))
r2 <- setValues(r1, runif(ncell(r1)))
rs <- r1 + r2
rp <- r1 * r2
par(mfrow=c(2,2))
plot(rs, main='sum')
plot(rp, main='product')
hist(rs)
a = hist(rp)
a

Run the code above in your browser using DataCamp Workspace