Skip to contents

This function joins two or more moveVis frames of equal lengths side-by-side into a single plot per frame using wrap_plots. This is useful if you want to side-by-side combine spatial frames returned by frames_spatial with graph frames returned by frames_graph.

Usage

join_frames(
  frames_list,
  guides = "collect",
  design = NULL,
  render_all_legends = FALSE,
  ...,
  frames_lists = NULL,
  verbose = T
)

Arguments

frames_list

list, a list of two or more moveVis frame objects that you want to combine into onw. Must be of equal lengths. Frames are being passed to wrap_plots and combined frame-by-frame.

guides

character, controls how to treat the scales/legends of both frames. See wrap_plots for details. Defaults to 'collect'.

design

character, controls how frames are arranged. See wrap_plots for details. By default, frames are joined sidy-by-side horizontally.

render_all_legends

logical, whether legends should be preserved (TRUE) or only the legend of the first frames object should be rendered (FALSE, default).

...

Further arguments, specifying the appearance of the joined ggplot2 objects, passed to wrap_plots. See wrap_plots for further options.

frames_lists

deprecated

verbose

logical, if TRUE, messages and progress information are displayed on the console (default).

Value

A frames object of class moveVis.

Examples

library(moveVis)
library(move2)
library(terra)

data("move_data", package = "moveVis")
r <- readRDS(example_data(file = "raster_NDVI.rds"))

# align movement
m <- align_move(move_data, res = units::set_units(4, "min"))
#> Temporal resolution of 4 [min] is used to align trajectories.

# create spatial frames 
frames_sp <- frames_spatial(m, r, r_type = "gradient", fade_raster = TRUE) %>% 
  add_colourscale(
    type = "gradient", colours = c("orange", "white", "darkgreen"),
    legend_title = "NDVI"
  )
#> Processing input data...
#> Approximated animation duration: ≈ 7.52s at 25 fps using 188 frames
#> CRS (geodetic):   WGS 84
#> Assigning raster maps to frames...

# create graph frames
frames_flow <- frames_graph(m, r, path_legend = FALSE, graph_type = "flow")
#> Processing input data...
#> Approximated animation duration: ≈ 7.52s at 25 fps using 188 frames
#> Extracting raster values per frame...
frames_hist <- frames_graph(m, r, path_legend = FALSE, graph_type = "hist")
#> Processing input data...
#> Approximated animation duration: ≈ 7.52s at 25 fps using 188 frames
#> Extracting raster values per frame...

# check lengths (must be equal)
sapply(list(frames_sp, frames_flow, frames_hist), length)
#> [1] 188 188 188

# define a patchwork design (see ?wrap_plots)
design <- "
AAB
AAC
"

# create joined frames
frames_joined <- join_frames(
  list(frames_sp, frames_flow, frames_hist), design = design
)
frames_joined[[100]]


# adjust width and height to suite your joined frames
if (FALSE) { # \dontrun{
out_file <- tempfile(fileext = ".gif")
animate_frames(
  frames_joined, out_file = out_file, fps = 25, width = 900, height = 500, 
  res = 90, display = TRUE, overwrite = TRUE
)
} # }