16EAGLE / moveVis

An R package providing 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.
http://www.movevis.org
GNU General Public License v3.0
131 stars 20 forks source link
animal-behavior animal-environment animal-movement animal-tracking animation movement-ecology movement-video r remote-sensing visualization

moveVis

CRAN version CRAN downloads CRAN checks R-CMD-check Coverage Package dependencies

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

Creating frames

Adapting frames

Animating frames (as GIF or video)

Viewing movement tracks

Methods

Processing settings

Examples

You can find code examples on how to use moveVis here:

Example 1: Creating a simple movement animation

Example 2: Customizing frames

Example 3: Using a mapbox satellite base map

Example 4: View movement tracks

Real-data example using White Storks (Ciconia ciconia) migration movement data [.docx]

Code snippets

These commented moveVis code snippets, addressing specific issues or questions, could also be helpful to you:

How to hold the last frame of an animation for a defined time and make it look good by using path_fade

How to display the full traces of each path using trace_show and trace_colour with frames_spatial()

How to colour paths based on a continuous variable

How to assign multiple path colours per individual, e.g. to indicate behavioral segments

How to adapt the path legend of frames created with frames_spatial()

How to create a data.frame containing each track coordinate per frame

How to overlay frames with additional transparent rasters changing over time (hacky, not a very optimal solution)

Further resources

Detailed code examples explaining how to use specific functions are provided at the function help pages. User contributions such as code examples or tutorials are very welcome and are linked below as soon as they have been spotted somewhere on the web:

Animating animal tracks from multiple years over a common year with moveVis: An example with Blue Whale Argos tracks on Movebank by Daniel M. Palacios, Marine Mammal Institute, Oregon State University

Reproducible example of how to combine animal tracking data, tidal water height data and a heightmap to visualize animal movement with moveVis by Henk-Jan van der Kolk, The Netherlands Institute of Ecology (NIOO-KNAW)

How to build animated tracking maps using tracking data in Movebank and environmental covariates in track and raster annotations from EnvDATA with moveVis by Sarah C. Davidson, Data Curator at Movebank

Mentions

Blog post: Featured article in Issue 11.5: Our May issue is now online! by Methods in Ecology and Evolution

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):

Related packages

Other R packages that might interest you:

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.

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