Skip to contents

This function implements the elevation preferences offset defined in Ellis‐Soto et al. (2021). The code here was adapted from the Supporting materials script.


add_offset_elevation(x, elev, pref, rate = 0.0089, add = TRUE)

# S4 method for BiodiversityDistribution,SpatRaster,numeric,numeric,logical



distribution() (i.e. BiodiversityDistribution) object.


A SpatRaster with the elevation for a given background.


A numeric vector of length 2 giving the lower and upper bound of known elevational preferences. Can be set to Inf if unknown.


A numeric for the rate used in the offset (Default: .0089). This parameter specifies the decay to near zero probability at elevation above and below the expert limits.


logical specifying whether new offset is to be added. Setting this parameter to FALSE replaces the current offsets with the new one (Default: TRUE).


Adds a elevational offset to a distribution object.


Specifically this functions calculates a continuous decay and decreasing probability of a species to occur from elevation limits. It requires a SpatRaster with elevation information. A generalized logistic transform (aka Richard's curve) is used to calculate decay from the suitable elevational areas, with the "rate" parameter allowing to vary the steepness of decline.

Note that all offsets created by this function are by default log-transformed before export. In addition this function also mean-centers the output as recommended by Ellis-Soto et al.


  • Ellis‐Soto, D., Merow, C., Amatulli, G., Parra, J.L., Jetz, W., 2021. Continental‐scale 1 km hummingbird diversity derived from fusing point records with lateral and elevational expert information. Ecography (Cop.). 44, 640–652.

  • Merow, C., Allen, J.M., Aiello-Lammens, M., Silander, J.A., 2016. Improving niche and range estimates with Maxent and point process models by integrating spatially explicit information. Glob. Ecol. Biogeogr. 25, 1022–1036.

See also


if (FALSE) {
 # Adds the offset to a distribution object
 distribution(background) |> add_offset_elevation(dem, pref = c(400, 1200))