trajLine: Climate velocity trajectory spatial lines

trajLineR Documentation

Climate velocity trajectory spatial lines

Description

Create a spatial line data frame object from trajectory points.

Usage

trajLine(x, projx)

Arguments

x

data.frame containing the coordinates (x, y) of the constituent points and identification number (trajIDs) for each trajectory as returned by VoCCTraj.

projx

CRS detailing the coordinate reference system of the input data (default geographic CRS).

Value

A SpatialLinesDataFrame with one line per trajectory as specified in x. To avoid artifacts, trajectories crossing the date line need to be split into two segments. Where the trajectory on one side of the date line is only composed of a single point, the trajectory won't be displayed (no line object created). The function assumes a -180 to 180 longitudinal arrangement.

Author(s)

Jorge Garcia Molinos

See Also

voccTraj

Examples


yrSST <- sumSeries(HSST, p = "1969-01/2009-12", yr0 = "1955-01-01", l = nlayers(HSST),
fun = function(x) colMeans(x, na.rm = TRUE), freqin = "months", freqout = "years")
tr <- tempTrend(yrSST, th = 10)
sg <- spatGrad(yrSST, th = 0.0001, projected = FALSE)
v <- gVoCC(tr,sg)
vel <- v[[1]]
ang <- v[[2]]

# calculate the annual SST mean over the period
mn <- mean(yrSST, na.rm = T)

# get the set of starting cells for the trajectories
lonlat <- na.omit(data.frame(xyFromCell(vel, 1:ncell(vel)), vel[], ang[], mn[]))[,1:2]

# Calculate trajectories.
traj <- voccTraj(lonlat, vel, ang, mn, tyr = 50, correct =TRUE)

# create a spatial line data frame from traj
lns <- trajLine(x = traj)
plot(mn)
plot(lns, add = TRUE)

# Export as ESRI shape file

rgdal::writeOGR(lns, ".", "velTraj", "ESRI Shapefile")


JorGarMol/VoCC documentation built on Aug. 17, 2022, 11:07 p.m.