Volume 11, Issue 5
APPLICATION
Open Access

moveVis: Animating movement trajectories in synchronicity with static or temporally dynamic environmental data in r

Jakob Schwalb‐Willmann

Corresponding Author

E-mail address: jakob.schwalb-willmann@uni-wuerzburg.de

Department of Remote Sensing, Institute of Geography and Geology, University of Würzburg, Würzburg, Germany

Correspondence

Jakob Schwalb‐Willmann

Email: jakob.schwalb-willmann@uni-wuerzburg.de

Search for more papers by this author
Ruben Remelgado

Group Macroecology and Society, German Centre for Integrative Biodiversity Research (iDiv) Halle‐Jena‐Leipzig, Leipzig, Germany

Search for more papers by this author
Kamran Safi

Lab for Computational Ecology, Max Planck Institute for Animal Behavior, Radolfzell, Germany

Search for more papers by this author
Martin Wegmann

Department of Remote Sensing, Institute of Geography and Geology, University of Würzburg, Würzburg, Germany

Search for more papers by this author
First published: 07 February 2020
Citations: 2

Abstract

  1. Visualizing movement data is challenging: While traditional spatial data can be sufficiently displayed as two‐dimensional plots or maps, movement trajectories require the representation of time in a third dimension. To address this, we present moveVis, an r package, which provides tools to animate movement trajectories, overlaying simultaneous uni‐ or multi‐temporal raster imagery or vector data.
  2. moveVis automates the processing of movement and environmental data to turn such into an animation. This includes (a) the regularization of movement trajectories enforcing uniform time instances and intervals across all trajectories, (b) the frame‐wise mapping of movement trajectories onto temporally static or dynamic environmental layers, (c) the addition of customizations, for example, map elements or colour scales and (d) the rendering of frames into an animation encoded as GIF or video file.
  3. moveVis is designed to display interactions and concurrencies of animal movement and environmental data. We present examples and use cases, ranging from data exploration to visualizing scientific findings.
  4. Static spatial plots of movement data disregard the temporal dimension that distinguishes movement from other spatial data. In contrast, animations allow to display relocation in both time and space. We deem animations a powerful way to visually explore movement data, frame analytical findings and display potential interactions with spatially continuous and temporally dynamic environmental covariates.

1 INTRODUCTION

Movement trajectories are spatio‐temporal data, representing the change in the spatial location of a tracked individual or object over time (Dodge, Weibel, & Lautenschütz, 2008). Due to their temporal dimension, visualizing such data is challenging: Traditional static maps suitable to display both spatial vector data, such as points, lines and polygons, as well as spatially continuous raster data disregard the temporal dimension of spatio‐temporal data. Instead, a wide range of graphical options that can be added to a static map are commonly used to visually indicate temporal aspects of spatio‐temporal data. This may include line features or arrows, for example, to visualize the direction of a trajectory, symbols or text to annotate events of a particular time, and feature attributes such as colours or transparency (Andrienko & Andrienko, 2006; Nöllenburg, 2007). However, while the spatial intersections of multiple trajectories are visible on a static map, the missing temporal dimension makes it challenging to perceive whether the trajectories intersected each other at the same time or at different times, that is, whether the tracked individuals met each other or just visited the same locations subsequently. Extracting this kind of information becomes particularly difficult if movement trajectories intersect their own traces.

Three‐dimensional, static representations of space and time, also referred to as space–time cubes, use the x‐ and y‐axes to display the spatial dimensions of movement and the z‐axis to display time (Kjellin, Pettersson, Seipel, & Lind, 2008; Kjellin et al., 2008; Nöllenburg, 2007; Zhong, Zaki, Tourre, & Moreau, 2010). Thus, the temporal dimension is brought into relationship with the spatial dimensions and is visualized statically and in parallel to them. This way, space–time cubes allow to visualize temporal proportions of movement trajectories (MacEachren, 2004; Nöllenburg, 2007). However, based on the limitations of human perception of three‐dimensional space projected to a two‐dimensional static plane, it has been questioned whether space–time cubes are suitable to display certain movement properties in an intuitive and comprehensible manner to human vision (Kjellin et al., 2008; Kjellin, Pettersson, Seipel, & Lind, 2010). This includes absolute speed displayed as the slope of a trajectory's trace, as well as the relative speed of several trajectories, requiring the observer to compare multiple slope angles located in different positions and spatial directions within three‐dimensional space (Kjellin et al., 2008). A large volume of data may lead to overlaps of trajectories in space and time, and thus decrease the temporal resolution of the z‐axis to a level where the relational temporal differences become indistinguishable. While space–time cubes permit the inclusion of spatially continuous raster layers, for example, environmental data, in the x–y plane, time series and changing raster information are hard to integrate maintaining the integrity of the time domain along the z‐axis.

Animations, in contrast, utilize a screen to display sequences of spatial frames one‐after‐another with sufficient speed to create an illusion of continuous transformation of the displayed frames (Andrienko et al., 2010; Nöllenburg, 2007). By this, animations relate the temporal dimension of the displayed data to actual time (Nöllenburg, 2007). A variety of r packages already exists to create animations, including the gganimate package for turning ggplot2 plots into animations (Pedersen, Robinson, & RStudio, 2019; Wickham, 2016), the animation package focusing on statistical animations (Xie, Mueller, Yu, & Zhu, 2018) or plotly for creating interactive animations (Sievert et al., 2018). These packages offer generic interfaces to compute animations for many kinds of data, but they are not specifically designed for dealing with spatio‐temporal data in general and to combine movement trajectories and environmental data in particular. To simplify creating movement animations in r, we have developed moveVis, an r package providing tools to jointly animate movement trajectories and uni‐ or multi‐temporal environmental data, such as remote sensing imagery. It thereby complements a range of data visualization r packages specifically designed for the study of Ecology and Evolution, including ggtree for visualizing phylogenetic trees, cheddar for visualizing ecological communities or haplostrips for visualizing haplotypes (Hudson et al., 2013; Marnetto & Huerta‐Sánchez, 2017; Yu, Smith, Zhu, Guan, & Lam, 2017). Here, we describe the moveVis user functions, explain their technical implementation, provide use cases and discuss its strengths and limitations.

2 SOFTWARE AND EXAMPLES

Each moveVis function is dedicated to one of four computational steps, which include (a) preparing data, (b) creating frames, (c) adapting frames and (d) animating frames (Figure 1). To represent movement trajectories and environmental data, moveVis uses the move and raster classes implemented in the move and raster packages (Hijmans, 2019; Kranstauber, Smolla, & Scharf, 2018). We illustrate the use of the package with a temporal subset of GPS data covering migratory movements of white storks Ciconia ciconia collected by Cheng, Fiedler, Wikelski, and Flack (2019) and Fiedler et al. (2019). The temporal subset is included in moveVis as an example dataset.

image
Schematic outline of the processing workflow of moveVis, displaying each major computational step to turn movement trajectories into an animation

With the function align_move, moveVis prepares movement trajectories for animation by aligning them to a regular time‐scale with a consistent temporal resolution throughout the complete movement sequence. Aligning movement trajectories is necessary for assigning trajectory positions to frames representing discrete times. A user defines a temporal resolution (sampling rate) to which the trajectories are aligned, as well as a time digit of a specific temporal unit to which the trajectories’ time‐scale is aligned, e.g. as follows:

  • library(moveVis)

  • data("whitestork_data")

  • m <- align_move(m, res = 180, digit = 0, unit = "mins")

If necessary, moveVis spatially interpolates the coordinates of the movement trajectories using interpolation along the great‐circle path, along a rhumb line or by Euclidean distance, as implemented in move (Kranstauber et al., 2018).

Once aligned, moveVis turns movement trajectories into sequences of frames, assigning sets of trajectory coordinates to individual frames. In addition, moveVis provides the option to add trajectory traces, indicating the past positions that can be faded in both size and colour. Each frame is drawn using ggplot2, an implementation of the grammar of graphics (Wickham, 2016; Wilkinson, 2006). Two types of frames can be created: (a) spatial frames using the function frames_spatial and (b) graph frames using the function frames_graph. Spatial frames display movement trajectories mapped to a spatial map. A variety of default, temporally static base maps, including OpenStreetMap, Carto and Mapbox products, are supported by moveVis and can be selected by the user, when creating frames:

  • frames <‐ frames_spatial(m, trace_show = TRUE, equidistant = FALSE, map_service = "osm", map_type = "terrain_bg")

  • frames[[200]] #plots a single frame

As an example, Figure 2 shows the single spatial frame created from the migration movements of white storks C. ciconia on a terrain base map (Cheng et al., 2019; Fiedler et al., 2019). For retrieving and composing base maps, moveVis utilizes slippymath, an r package for dealing with Slippy Map tile servers (McBain & Sumner, 2019). Alternatively, the user has the option to provide custom uni‐ or multi‐temporal raster imagery, both single‐ (gradient/discrete) or multi‐band (RGB) (Hijmans, 2019).

image
A single spatial frame, displaying the migration movements of white storks Ciconia ciconia on a terrain base map

Graph frames, in contrast, display movement trajectories as two‐dimensional, non‐spatial graphs. They can be used to visualize movement–environment interactions, for example, as a time flow graph, displaying frame time on the x‐axis and the values of cells visited by individuals on the y‐axis, or as cumulative histogram, with cell values on the x‐axis and the individuals’ time‐cumulative counts of visited cells on the y‐axis.

The created frames can be further customized, either using the adaption functions implemented in moveVis starting with the prefix ‘add_’, general ggplot2 functions or a combination of both. This allows to adapt colour scales and add temporally static or dynamic elements to a sequence of frames or parts of it, including text annotations, labels and timestamps or point, line and polygon vector features, for example, as follows:

  • frames <‐ frames %>%

  • add_labels(title = "White Storks (Ciconia ciconia) Migration 2018",

  • caption = "Trajectory data: Cheng et al. ();

  • Fiedler et al. (2013‐2019),https://doi.org/10.5441/001/1.ck04mn78

  • Map: OpenStreetMap/Stamen; Projection: Geographic, WGS84",

  • x = "Longitude", y = "Latitude") %>%

  • add_timestamps(type = "label") %>%

  • add_progress(colour = "white") %>%

  • add_northarrow(colour = "white", position = "bottomleft") %>%

  • add_scalebar(colour = "black", position = "bottomright", distance = 600)

  • frames[[200]] #plots a single frame

As an example, Figure 3 displays the single spatial frame which has been adapted to add additional information on the used data and its scales.

image
A single spatial frame, displaying the migration movements of white storks Ciconia ciconia on a terrain base map with added information on data and its scales

Multiple sequences of frames can be combined into a single sequence, for example, to display spatial frames and graph frames side by side, for which moveVis utilizes the cowplot package (Wilke & RStudio, 2019). With the function animate_frames, frames can finally be rendered into an animation, using the gifski and av packages to create GIF and video files (Ooms, 2018a; Ooms & Lesiński, 2018). A detailed worked example using migratory movement trajectories of white storks, the resulting video animations and an overview of all moveVis functions and their purposes can be found in the Supporting Information (S1–S5).

The computational time necessary to create an animation mainly depends on the writing speed of the hardware used. For example, rendering an animation of 500 frames with 25 frames per second, resulting in an animation duration of 20 s, takes approximately 25–35 min. The maximum number of frames that can be animated with moveVis is thus hardware limited. Since the number of timestamps in a trajectory governs the number of frames created, the user can control the computational cost of an animation by choosing an optimal temporal resolution for aligning the trajectories.

Beyond the named packages, moveVis depends on the r base packages (R Core Team, 2018), sf (Pebesma, 2018), geosphere (Hijmans, Williams, & Vennes, 2017), RStoolbox (Leutner, Horning, & Schwalb‐Willmann, 2019), lubridate (Grolemund & Wickham, 2011), dplyr (Wickham, 2011; Wickham, François, Henry, & Müller, 2018), zoo (Zeileis & Grothendieck, 2005), magick (Ooms, 2018b), rlang (Henry & Wickham, 2019), magrittr (Bache & Wickham, 2014) and pbapply (Solymos & Zawadzki, 2018).

3 USE CASES

The moveVis package has been designed to animate primarily animal movement trajectories on top of a variety of default, out‐of‐the‐box base maps, each of its own character. Informative animations can be created directly from movement trajectories without manually acquiring appropriate base map imagery first. Therefore, moveVis may be useful to create animations for the exploration of movement data prior to analysis. Such animations may guide the observer towards certain movement patterns or trajectory characteristics that might be worth of further investigation and would not have been easy to identify using static visualizations. Exploratory animations of movement trajectories with custom base map imagery, for example, to visually explore patterns in animal–environment interactions using variables such as vegetation indices or land cover classifications, can provide similar advantages. Apart from data exploration, moveVis may be considered as a suitable tool to visualize datasets and frame research findings, for example, ranging from local movements recorded with high sampling rates to large‐scale, long‐term migratory trajectories. Such animations may be useful to communicate with scientific audiences, such as colleagues, collaborators or members of other scientific fields, and non‐scientific audiences, such as representatives of funding agencies, decision‐makers or the general public. Various media may be used to display and share animations with different communities, including presentations, digital posters or web services like Twitter.

4 DISCUSSION

Animations can be considered as a powerful way to visualize spatio‐temporal data, both point‐featured and spatially continuous. Static techniques to visualize spatio‐temporal data such as maps or space–time cubes clearly have the advantage of capturing a multidimensional process into a single, static graph. These types of visualizations can be paper‐printed, viewed and examined in detail, independent from actual time and not requiring the use of video‐capable hardware and software (Nöllenburg, 2007). Although experimental evidence indicates that there is a limit of how many individual movements can be simultaneously perceived by human vision (Pylyshyn & Storm, 1988; Tran & Hoffman, 2016; Verghese & Pelli, 1992), animations ease the intuitive understanding of spatio‐temporal information and thus the properties of movement trajectories (Koussoulakou & Kraak, 1992; MacEachren, Boscoe, & Pickle, 1998). This includes absolute and relational speeds, variability in location and direction as well as potential interactions of individuals with each other and their environment. However, since the content displayed by an animation is changing continuously with time, it requires constant attention and thus pertains the risk that observers may miss information (Andrienko et al., 2010; Nöllenburg, 2007). Animation properties such as speed, overall duration and repetition cycle may highly influence the way the displayed data are perceived.

While moveVis simplifies the task of turning movement trajectories into animations, it is clear that the latter may not always be the optimal visualization choice. The type of visualization best suitable to transport a certain information must be chosen unbiased by a potential personal aesthetic preference: For example, an animation itself may seem to be visually more interesting than another type of visualization, regardless of the displayed content. Compared to generic animation r packages such as gganimate or plotly, the utility of moveVis is more specific yet less flexible (Pedersen, Robinson, & RStudio, 2019; Sievert et al., 2018). Similarly, other visualization packages built for Ecology and Evolution research, such as ggtree, cheddar or haplostrips, simplify creating specific types of visualizations commonly used within the corresponding scientific disciplines (Hudson et al., 2013; Marnetto & Huerta‐Sánchez, 2017; Yu et al., 2017). We deem moveVis to be a useful tool for visually exploring and interpreting movement patterns, including potential interactions of individuals with each other and their environment, and communicate such patterns appropriately to different kinds of audiences.

AUTHORS' CONTRIBUTIONS

J.S.‐W., R.R., M.W. and K.S. conceived the idea; J.S.‐W. designed the software; R.R., M.W. and K.S. contributed with feature ideas; J.S.‐W. led the writing of the manuscript. All authors contributed critically and approved the publication.

DATA AVAILABILITY STATEMENT

The moveVis source code has been published under the GNU General Public License 3 on GitHub (https://github.com/16eagle/moveVis). The package can be installed from CRAN https://CRAN.R‐project.org/package=moveVis (Schwalb‐Willmann, 2020). A user manual can be accessed at http://movevis.org.

    Number of times cited according to CrossRef: 2

    • Hidden Long-Distance Movements by a Migratory Bird, Current Biology, 10.1016/j.cub.2020.07.056, (2020).
    • The timing of breeding and independence for snow leopard females and their cubs, Mammalian Biology, 10.1007/s42991-020-00073-3, (2020).