knitr::opts_chunk$set(collapse = TRUE, comment = "#>") options(knitr.table.format = "html", rmarkdown.html_vignette.check_title = FALSE) library(eRTG3D) set.seed(123)
This vignette illustrates the basic functionality of the
eRTG3D package and some workflows, to combine the functions in a meaningful way. For a more detailed description of the individual functions and their parameters please consider the package's help.
As first step the properties of a track with x, y and z coordinates are calculated.
niclas <- track.properties.3d(niclas)
niclas <- track.properties.3d(niclas) pander::pandoc.table(head(round(niclas, 2),5))
Then the movement characteristics (P probability) are extracted from the trajectory. Although the algorithm also works without a DEM, the DEM should be passed to the
get.track.densities.3d() function, otherwise the flight height distribution in respect to the earth surface can not be built, which ends in less accurate results.
P <- get.track.densities.3d(niclas, heightDistEllipsoid = TRUE, DEM = dem)
The finally desired Conditional Empirical Random Walk (CERW) connecting a given start with a certain end point by a given number of steps needs an attraction term (the Q probability) to ensure that the target is approached and hit.
In order to calculate the Q probability for each step the distribution of turns and lifts to target and the distribution of distance to target has to be known. They can be derived from the empirical data (ideally),
or estimated from an unconditional process with the same properties. In this case the Q probabilities, which represent the pull towards the destination, are extracted from a UERW simulated with
sim.uncond.3d(). The UERW should contain 1500
f <- 1500 times more steps than the final CERW to be simulated. Q are extracted from the UERW by the function
sim.locs <- nrow(niclas) f <- 1500 uerw <- sim.uncond.3d(sim.locs*f, start = c(niclas$x, niclas$y, niclas$z), a0 = niclas$a, g0 = niclas$g, densities = P) Q <- qProb.3d(uerw, sim.locs)
Set up the start and end conditions: azimuth (
a0), gradient (
g0), start and end point of the CERW to be simulated.
start <- c(niclas$x, niclas$y, niclas$z) end <- c(niclas$x[nrow(niclas)], niclas$y[nrow(niclas)], niclas$z[nrow(niclas)]) a0 <- niclas$a g0 <- niclas$g
Then finally a CERW can be simulated.
cerw <- sim.cond.3d(sim.locs, start = start, end = end, a0 = a0, g0 = g0, densities = P, qProbs = Q, DEM = dem)
If more than one simulated track is desired, the
n.sim.cond.3d() can be used. The n.sim parameter defines the number of simulated tracks.
cerwList <- n.sim.cond.3d(n.sim = 100, sim.locs, start = start, end = end, a0 = a0, g0 = g0, densities = P, qProbs = Q, DEM = dem)
Note: Due to dead ends, which are normally occurring in a proportion of 25%, the n.sim parameter should be set higher than the needed tracks.
In many cases the time between the acquisition of fix points of the GPS tracks is not constant.
This can be caused by the time to get the fix point or missing data. To avoid distorted statistic distributions,
which increases the probability of dead ends, the track has to be splitted in sections, where the acquisition time is constant. In this case the
get.track.properties.3d() function can not be used anymore. Then the work flow should look like the following:
trackSections <- track.split.3d(track, timeLag) P <- get.section.densities.3d(trackSections, DEM = dem)
Note: If the aim is to reproduce a track, then the length of the track should be adjusted to fit to the densities extracted by
get.section.densities.3d(). The message thrown by the previously applied
track.split.3d() proposes a value
nChange to adjust the track length of the simulations.
To reproduce an observed track, it is the simplest to just apply the
reproduce.track.3d() function on the track and the DEM. The function automatically wraps all steps above together. To produce multiple tracks, the
n.sim variable can be used.
cerwList <- reproduce.track.3d(n.sim = 100, niclas, DEM = dem)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.