Function to calculate vocc trajectories after Burrows et al (2014). Trajectories are calculated by propagating climatic isopleths using the magnitude and direction of local (cell) velocities. This is a slightly modified version of the original Burrows et al. (2014) approach in that iterations of a trajectory are based on cumulative time traveled instead of using fixed time steps.
Arguments
- lonlat
data.frame
with the longitude and latitude (in decimal degrees) of the points to project.- vel
raster
with the magnitude of gradient-based climate velocity.- ang
raster
with velocity angles in degrees.- mn
raster
with the overall mean climatic value over the period of interest.- tyr
integer
temporal length of the period of interest.
Value
a data.frame
containing the coordinates ("x", "y") of the constituent
points and identification number ("trajIDs") for each trajectory.
References
Burrows et al. 2014. Geographical limits to species-range shifts are suggested by climate velocity. Nature, 507, 492-495.
Examples
if (FALSE) { # \dontrun{
yrSST <- sumSeries(HSST,
p = "1960-01/2009-12", yr0 = "1955-01-01", l = terra::nlyr(HSST),
fun = function(x) colMeans(x, na.rm = TRUE),
freqin = "months", freqout = "years"
)
# Long-term local climatic trends
tr <- tempTrend(yrSST, th = 10)
# Local spatial climatic gradients
sg <- spatGrad(yrSST, th = 0.0001, projected = FALSE)
# Gradient-based climate velocity
v <- gVoCC(tr, sg)
vel <- v[[1]]
ang <- v[[2]]
# Calculate the annual SST mean over the period
mn <- terra::mean(yrSST, na.rm = TRUE)
# Get the set of starting cells for the trajectories
lonlat <- stats::na.omit(data.frame(
terra::xyFromCell(vel, 1:terra::ncell(vel)),
vel[], ang[], mn[]
))[, 1:2]
# Calculate trajectories
# The following throws an error due to the trajectories moving beyond the raster extent
traj <- voccTraj(lonlat, vel, ang, mn, tyr = 50)
# This accounts for the extent issue
traj <- voccTraj(lonlat, vel, ang, mn, tyr = 50, correct = TRUE)
} # }