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.
Usage
voccTraj(
lonlat,
vel,
ang,
mn,
x_res,
y_res,
tstep,
tyr = 20,
bfr = 75,
grid_resolution = "coarse"
)
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.- x_res
Numeric. Resolution of the grid in longitude direction (degrees or km).
- y_res
Numeric. Resolution of the grid in latitude direction (degrees or km).
- tstep
Numeric. Timestep for each trajectory iteration (usually decimal year).
- tyr
Integer. Temporal length of the period of interest (years).
- grid_resolution
Character. "coarse" (default) or "fine". Controls how land crossings are handled and allows for higher resolution grids.
Value
a tibble
containing the coordinates ("lon", "lat") of the constituent
points, time step ("Steps"), identification number ("ID") for each trajectory, and cell IDs for start and end cells.
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)
} # }