density function

Density plot

Density plot

Create density plots of the cell values of a SpatRaster methods

## S4 method for signature 'SpatRaster' density(x, maxcells=100000, plot=TRUE, main, ...)

Arguments

  • x: SpatRaster
  • maxcells: the maximum number of (randomly sampled) cells to be used for creating the plot
  • plot: if TRUE produce a plot, else return a density object
  • main: character. Caption of plot(s)
  • ...: additional arguments passed to plot

Returns

density plot (and a density object, returned invisibly if plot=TRUE)

Examples

logo <- rast(system.file("ex/logo.tif", package="terra")) density(logo)
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2025-02-26

Downloads (last 30 days):