Introduction

moveVis provides tools to visualize movement data (e.g. from GPS tracking) and temporal changes of environmental data (e.g. from remote sensing) by creating video animations. It works with move and raster class inputs and turns them into ggplot2 frames that can be further customized. moveVis uses gifski (wrapping the gifski cargo crate) and av (binding to FFmpeg) to render frames into animated GIF or video files.

A peer-reviewed open-access paper accompanying moveVis has been published in Methods in Ecology and Evolution.


Figure 1: Example movement tracks nearby Lake of Constance on top of a OSM watercolor and a mapbox satellite base map



Figure 2: Example movement tracks nearby Lake of Constance and a gradient base layer faded over time

Installation

With version 0.10.0, the package has been rewritten from the ground up with the goal to make it easier to customize the appearance of movement animations. Thus, the logic of the package, its functions and their syntax have changed.

The latest stable version of moveVis can be installed from CRAN:

install.packages("moveVis")

The development version can be installed from GitHub:

devtools::install_github("16EAGLE/moveVis")

Code written for moveVis version <=0.9.9 will not work with newer versions, but it is quite simple and thus highly recommended to switch to the new syntax due to a variety of advantages. moveVis version <=0.9.9 can still be downloaded here and installed manually:

setwd("your/download/directory")
install.packages("moveVis-0.9.9.tar.gz", repos = NULL)

Get started

The following example shows how to make a simple animation using a default basemap by first aligning your movement data to a uniform time scale, creating frames that can be viewed or modified using ggplot2 or add*() functions and turning these frames into an animated GIF:

library(moveVis)
library(move)

data("move_data", package = "moveVis") # move class object
# if your tracks are present as data.frames, see df2move() for conversion

# align move_data to a uniform time scale
m <- align_move(move_data, res = 4, unit = "mins")

# create spatial frames with a OpenStreetMap watercolour map
frames <- frames_spatial(m, path_colours = c("red", "green", "blue"),
                         map_service = "osm_stamen", map_type = "watercolor", alpha = 0.5) %>% 
  add_labels(x = "Longitude", y = "Latitude") %>% # add some customizations, such as axis labels
  add_northarrow() %>% 
  add_scalebar() %>% 
  add_timestamps(type = "label") %>% 
  add_progress()

frames[[100]] # preview one of the frames, e.g. the 100th frame

# animate frames
animate_frames(frames, out_file = "moveVis.gif")

Function overview

moveVis includes the following functions, sorted by the order they would be applied to create an animation from movement and environmental data:

Preparing movement tracks

  • df2move() converts a data.frame into a move or moveStack object. This is useful if you do not usually work with the move classes and your tracks are present as data.frames.
  • align_move() aligns single and multi-individual movement data to a uniform time scale with a uniform temporal resolution needed for creating an animation from it. Use this function to prepare your movement data for animation depending on the temporal resolution that suits your data.
  • subset_move() subsets a move or moveStack by a given time span. This is useful if you want to create a movement animation of only a temporal subset of your data, e.g. a particular day.

Creating frames

  • get_maptypes() returns a character vector of available map types that can be used with frames_spatial(). moveVis supports OpenStreetMap and Mapbox basemap imagery. Alternatively, you can provide custom imagery to frames_spatial().
  • frames_spatial() creates moveVis frames spatio-temporally displaying movement. Frames can be individually plotted using ggplot2, modified individually or as a whole using add*() functions, or animated using animate_frames().
  • frames_graph() creates moveVis frames displaying movement-environment interaction graphs. Frames can be individually plotted using ggplot2, modified individually or as a whole using add*() functions, or animated using animate_frames().

Adapting frames

Animating frames (as GIF or video)

Viewing movement tracks

  • render_frame() renders an individual frame. It yields the same result as if an individual frame is extracted using default subsetting [[.
  • view_spatial() displays movement tracks on an interactive mapview or leaflet map.

Methods

  • [ extracts individual frames or a sequence of frames from a moveVis frames object.
  • [[ renders an individual frame.
  • c combines multiple moveVis frames objects.
  • tail() and head() return n last or first frames of a moveVis frames object.
  • length() return length of moveVis frames, i.e. number of frames.
  • print() shows basic information about a moveVis frames object, i.e. number of frames, extent and more.
  • rev() reverses the order of a moveVis frames object.

Processing settings

  • use_multicore() enables multi-core usage for computational expensive processing steps.
  • use_disk() enables the usage of disk space for creating frames, which can prevent memory overload when creating frames for very large animations.

Features to be added

Things and features that should be added in future versions of moveVis (feel free to contribute to this list using a pull request):

  • follow population mode
  • follow individual mode
  • 3D animations, e.g. for including altitude data

Other R packages that might interest you:

  • basemaps, a package to download and cache spatial basemaps from open sources such as OpenStreetMap, Stamen, Thunderforest, Carto, Mapbox and others,
  • getSpatialData, a package to query, preview and download satellite data,
  • RStoolbox, a package providing a wide range of tools for every-day remote sensing processing needs,
  • rsMove, a package providing tools to query and analyze movement data using remote sensing.

Acknowledgements

This initiative was part of the Opt4Environment project and had been funded by the German Aerospace Center (DLR) on behalf of the Federal Ministry for Economic Affairs and Energy (BMWi) with the research grant 50 EE 1403.

<a href="https://www.geographie.uni-wuerzburg.de/en/fernerkundung/startseite/"><img width="29%" src="https://www.uni-wuerzburg.de/typo3conf/ext/uw_sitepackage/Resources/Public/Images/uni-wuerzburg-logo.svg"></a>
<a href="http://www.dlr.de/eoc/en/"><img width="16%" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f5/DLR_Logo.svg/744px-DLR_Logo.svg.png"></a>
 <a href="https://www.bmu.de/en/"><img width="29%" src="https://upload.wikimedia.org/wikipedia/commons/b/b1/Logo_Bundesministerium_f%C3%BCr_Umwelt_Naturschutz_und_nukleare_Sicherheit.png"></a>
<a href="https://www.ab.mpg.de/"><img width="16%" src="https://www.mpg.de/assets/og-logo-8216b4912130f3257762760810a4027c063e0a4b09512fc955727997f9da6ea3.jpg"></a>

Citation

An open-access paper accompanying the moveVis R package has been peer-reviewed by and published in ‘Methods in Ecology and Evolution’ (see https://doi.org/10.1111/2041-210X.13374). Please cite moveVis, e.g. when you use it in publications or presentations, using the output of citation("moveVis") or as follows:

Schwalb-Willmann, J.; Remelgado, R.; Safi, K.; Wegmann, M. (2020). moveVis: Animating movement trajectories in synchronicity with static or temporally dynamic environmental data in R. Methods Ecol Evol. 2020; 11: 664–669. https://doi.org/10.1111/2041-210X.13374