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

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. 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. 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. 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.


| INTRODUC TI ON
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.

| SOF T WARE AND E X AMPLE S
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 F I G U R E 1 Schematic outline of the processing workflow of movevis, displaying each major computational step to turn movement trajectories into an animation (2019) and Fiedler et al. (2019). The temporal subset is included in movevis as an example dataset.
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). 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).
Graph frames, in contrast, display movement trajectories as two-dimensional, non-spatial graphs. They can be used to visualize 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.

F I G U R E 2
A single spatial frame, displaying the migration movements of white storks Ciconia ciconia on a terrain base map 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: 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.
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). pbapply (Solymos & Zawadzki, 2018).

F I G U R E 3
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

| US E C A S E S
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.

| D ISCUSS I ON
Animations can be considered as a powerful way to visualize spatiotemporal 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 videocapable 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 spatiotemporal 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 led the writing of the manuscript. All authors contributed critically and approved the publication.

DATA AVA I L A B I L I T Y S TAT E M E N T
The movevis source code has been published under the GNU General Public License 3 on GitHub (https://github.com/16eag le/moveVis).