animate_paths {anipaths} | R Documentation |
animate paths
Description
Animates telemetry data for the purposed of EDA using smoothing splines to interpolate the observed locations. The animations are particularly useful when examining multiple simultaneous trajectories. The output of the call to animate_paths()
should bring up a browser window that shows the animation. Additionally, the images generated in images/
(or else the value set for imgdir
) may be used with ffmpeg, latex, or other presentation software that can build animations directly from a sequence of images.
Usage
animate_paths(
paths,
coord = c("x", "y"),
Time.name = "time",
background = NULL,
bg.axes = TRUE,
bg.misc = NULL,
bg.opts = NULL,
blur.size = 8,
covariate = NULL,
covariate.colors = c("black", "white"),
covariate.legend.loc = "bottomright",
covariate.thresh = NULL,
crawl.mu.color = "black",
crawl.plot.type = "point.tail",
date.col = "black",
delta.t = NULL,
dev.opts = list(),
dimmed = NULL,
ID.name = NULL,
interpolation_type = "gam",
interval = 1/12,
legend.loc = "topright",
main = NULL,
max_refit_attempts = 10,
method = "html",
n.frames = NULL,
network = NULL,
network.colors = NULL,
network.thresh = 0.5,
network.times = NULL,
network.ring.trans = 1,
network.ring.wt = 3,
network.segment.trans = 0.5,
network.segment.wt = 3,
override = FALSE,
par.opts = list(),
paths.proj = "+proj=longlat",
paths.tranform.crs = "+proj=aea",
plot.date = TRUE,
pt.alpha = 0.4,
pt.cex = 1,
pt.colors = NULL,
pt.wd = 1,
res = 1.5,
return.paths = FALSE,
s_args = NULL,
simulation = FALSE,
simulation.iter = 12,
tail.alpha = 0.6,
tail.colors = "gray87",
tail.length = 5,
tail.wd = 1,
theme_map = NULL,
times = NULL,
uncertainty.level = NA,
uncertainty.type = 1,
whole.path = FALSE,
xlim = NULL,
ylim = NULL,
verbose = FALSE,
...
)
Arguments
paths |
Either a |
coord |
A character vector of length 2 giving the names of the longitude/easting and latitude/northing columns in the |
Time.name |
The name of the columns in |
background |
Three possibilities: (1) A single background image over which animation will be overlayed, or a SpatRaster objects with one layers corresponding to each frame. (2) A list with values |
bg.axes |
logical: should animation place axis labels when using a background image (default is |
bg.misc |
Character string which will be executed as |
bg.opts |
Options passed to |
blur.size |
a integer of the size for blur points; default is 8 |
covariate |
The name of the column in |
covariate.colors |
vector of colors which will be used in their given order to make a color ramp (see |
covariate.legend.loc |
either the location of the covariate legend, or |
covariate.thresh |
if changed from its default value of |
crawl.mu.color |
color for the main predictions for crawl interpolation; default is black |
crawl.plot.type |
a character string of what type of the plot you wish to generate when |
date.col |
default is |
delta.t |
The gap in time between each frame in the animation. Specify one of |
dev.opts |
Options passed to |
dimmed |
Numeric vector of individuals to "dim" in the animation. Order corresponds to the order of the ID.name variable, or order of paths list. |
ID.name |
The name of the column in |
interpolation_type |
a character string of the type of interpolation. Default is "gam" for a generalized addictive model. Use "crawl" to interpolate using |
interval |
Seconds per frame in animation. Default is 1/12 (or 12 frames per second). |
legend.loc |
passed to first argument of |
main |
Title for each frame. |
max_refit_attempts |
an integer of number of resampling when the fit for crawl failed to run; default is 10 |
method |
either |
n.frames |
The number of frames used to animate the complete time domain of the data. |
network |
Array of dimensions (# individuals, # individuals, |
network.colors |
A symmetric matrix of dimension |
network.thresh |
Network structure is summarized in the animation in a binary way, regardless of whether or not the |
network.times |
Numeric vector. If network time grid doesn't match |
network.ring.trans |
transparency of network segments (default is 1) |
network.ring.wt |
thickness of network rings (default is 3) |
network.segment.trans |
transparency of network segments (default is 0.5) |
network.segment.wt |
thickness of network segments (default is 3) |
override |
Logical variable toggling where or not to override warnings about how long the animation procedure will take. |
par.opts |
Options passed to |
paths.proj |
PROJ.4 string corresponding to the projection of the data. Default is "+proj=longlat". |
paths.tranform.crs |
a PROJ.4 string of coordinate projection transformation based on the animals' location; default is "+proj=aea +lat_1=30 +lat_2=70". |
plot.date |
Logical variable toggling date text at the time center of the animation. |
pt.alpha |
alpha value for the points |
pt.cex |
A numeric value giving the character expansion (size) of the points for each individual. Default is 1. |
pt.colors |
A vector of colors to be used for each individual in the animation. Default values come from Color Brewer palettes. When a network is provided, this is ignored and individuals are all colored black. If |
pt.wd |
size of the points; default is 1 |
res |
Resolution of images in animation. Increase this for higher quality (and larger) images. |
return.paths |
logical. Default is |
s_args |
Default is |
simulation |
logical. Generate simulation predictions to have multiple projects for the animal paths; default is |
simulation.iter |
an integer of how many paths the crawl model will generate; default is 5. |
tail.alpha |
alpha value for the tails |
tail.colors |
default is |
tail.length |
Length of the tail trailing each individual. |
tail.wd |
Thickness of tail trailing behind each individual. Default is 1. |
theme_map |
plot theme for |
times |
If all paths are already synchronous, another option for passing the data is to define |
uncertainty.level |
value in (0, 1) corresponding to |
uncertainty.type |
State what type of uncertainty plot 1 is default for tails more than 1 is amount of predicted trajectories for each unique individual and blurs for blur plot |
whole.path |
logical. If |
xlim |
Boundaries for plotting. If left undefined, the range of the data will be used. |
ylim |
Boundaries for plotting. If left undefined, the range of the data will be used. |
verbose |
logical; |
... |
other arguments to be passed to |
Value
video file, possibly a directory containing the individual images, or interpolated paths.
Examples
##
vultures$POSIX <- as.POSIXct(vultures$timestamp, tz = "UTC")
vultures_paths <- vultures[vultures$POSIX > as.POSIXct("2009-03-01", origin = "1970-01-01") &
vultures$POSIX < as.POSIXct("2009-05-01", origin = "1970-01-01"), ]
animate_paths(
paths = vultures_paths,
delta.t = "week",
coord = c("location.long", "location.lat"),
Time.name = "POSIX",
ID.name = "individual.local.identifier"
)
## Not run:
background <- list(
center = c(-90, 10),
zoom = 3,
maptype = "satellite"
)
library(ggmap)
library(RColorBrewer)
COVARIATE <- cos(as.numeric(vultures_paths$timestamp) /
diff(range(as.numeric(vultures_paths$timestamp))) * 4 * pi)
animate_paths(
paths = cbind(vultures_paths, COVARIATE),
delta.t = "week",
coord = c("location.long", "location.lat"),
Time.name = "POSIX", covariate = "COVARIATE",
covariate.colors = brewer.pal(n = 9, "RdYlGn"),
ID.name = "individual.local.identifier",
background = background
)
# animation using crawl interpolation
animate_paths(
paths = vultures_paths,
delta.t = "week",
coord = c("location.long", "location.lat"),
Time.name = "POSIX",
ID.name = "individual.local.identifier",
interpolation_type = "crawl"
)
## End(Not run)
# Run to remove files generated by this function
system("rm -r js; rm -r css; rm -r images; rm index.html")