trajLine | R Documentation |
Create a spatial line data frame object from trajectory points.
trajLine(x, projx)
x |
|
projx |
|
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.
Jorge Garcia Molinos
voccTraj
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.