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.
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
, sp
and raster
class inputs and turns them into ggplot2
frames that can be further customized. moveVis
uses gifski
(wraping the gifski cargo crate) and av
(binding to FFmpeg) to render frames into animated GIF or video files.
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.
moveVis
0.10.2 (stable) 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)
moveVis
includes the following functions, sorted by the order they would be applied to create an animation from movement and environmental data:
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.get_maptypes()
returns a character vector of available map types that can be used with frames_spatial()
. moveVis
supports OpenStreetMaps and Mapbox basemap imergay. Alternatively, you can provide custom imagery to frames_spatial()
.frames_spatial()
creates a list of ggplot2
maps displaying movement. Each object represents a single frame. Each frame can be viewed or modified individually. The returned list of frames can be animated using animate_frames()
.frames_graph()
creates a list of ggplot2
graphs displaying movement-environment interaction. Each object represents a single frame. Each frame can be viewed or modified individually. The returned list of frames can be animated using animate_frames()
.add_gg()
adds ggplot2
functions (e.g. to add layers such as points, polygons, lines, or to change scales etc.) to the animation frames created with frames_spatial()
or frames_graph()
. Instead of creating your own ggplot2
functions, you can use one of the other moveVis
`add_``functions:add_labels()
adds character labels such as title or axis labels to animation frames created with frames_spatial()
or frames_graph()
.add_scalebar()
adds a scalebar to the animation frames created with frames_spatial()
or frames_graph()
.add_northarrow()
adds a north arrow to the animation frames created with frames_spatial()
or frames_graph()
.add_progress()
adds a progress bar to animation frames created with frames_spatial()
or frames_graph()
.add_timestamps()
adds timestamps to animation frames created with frames_spatial()
or frames_graph()
.add_text()
adds static or dynamically changing text to the animation frames created with frames_spatial()
or frames_graph()
.add_colourscale()
adjusts the colour scales of the animation frames created with frames_spatial()
and custom map imagery using the r_list
argument.join_frames()
side-by-side joins the ggplot2
objects of two or more frames lists of equal lengths into a single list of ggplot2
objects per frame using cowplot::plot_grid
. This is useful if you want to side-by-side combine spatial frames returned by frames_spatial()
with graph frames returned by frames_graph()
.get_frametimes()
extracts the timestamps associated with each frame of a list of frames created using frames_spatial()
or frames_graph()
and returns them as a vector.suggest_formats()
returns a selection of suggested file formats that can be used with out_file
of animate_frames()
on your system.animate_frames()
creates an animation from a list of frames computed with frames_spatial()
, frames_graph()
or join_frames()
.view_spatial()
displays movement tracks on an interactive mapview
or leaflet
map.The following example shows how to make a simple animation using a default base map by first aligning your movement data to a uniform time scale, creating a list of ggplot2
frames and turning these frames into an animated GIF
:
library(moveVis)library(move)library(magrittr)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 scalem <- align_move(move_data, res = 240, digit = 0, unit = "secs") # create spatial frames with a OpenStreetMap watercolour mapframes <- frames_spatial(m, path_colours = c("red", "green", "blue"), map_service = "osm", 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(m, type = "label") %>% add_progress() frames[[100]] # preview one of the frames, e.g. the 100th frame # animate framesanimate_frames(frames, out_file = "/full/path/to/moveVis.gif")
You can find code examples on how to use moveVis
here:
Example 1: Creating a simple movement animation
Example 3: Using a mapbox satellite base map
Example 4: Custom base maps from raster data (to be added soon)
Example 5: Interaction graphs (to be added soon)
Example 6: Joining frames side by side (to be added soon)
Example 7: View movement tracks
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 (requires moveVis
>= 0.10.2)
How to display the full traces of each path using trace_show and trace_colour with frames_spatial() (requires moveVis
>= 0.10.2)
How to assign multiple path colours per individual to indicate e.g. behavioral segments (requires moveVis
>= 0.10.1)
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 (not yet a optimal solution)
Detailed code examples explaining how to use specific functions are provided at the fucntion 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
Things and features that should be added in future versions of moveVis
(feel free to contribute to this list using a pull request):
Next version (0.10.2):
trace_show
and trace_colour
in frames_spatial()
)get_maptypes()
for bright and dark map types)Some day:
The Department of Remote Sensing of the University of Würzburg has developed other R packages that might interest you:
For other news on the work at at the Department of Remote Sensing of the University of Würzburg, click here.
This initiative is part of the Opt4Environment project and was 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.
Adding some small but practical features. Released on CRAN: 2019-04-30.
New features:
path_alpha
of frames_spatial()
for defining path transparency.tail_colour
of frames_spatial()
makes it now possible to define the colour of the last tail element, to which the path colour is faded. Default is "white".trace_show
of frames_spatial()
for displaying the trace of the complete path (instead that it vanishes after the tail).trace_colour
of frames_spatial()
for defining the colour of the trace.na.colour
of add_colourscale()
for defining the colouring of NA values.na.show
of add_colourscale()
to show or hide NA values in discrete background rasters.end_pause
of animate_frames()
to hold the last frame, adding a pause of a user-defined duration to the end of an animation.path_fade
of frames_spatial()
to define whether paths should be faded towards the last frame or not. Useful in combination with trace_show = T
and when using end_pause
of animate_frames()
.moveVis
now stores the timestamps represented by each frame as an attribute time
for each ggplot
frame. Frame times can now be accessed using get_frametimes()
.add_timestamps()
can now extract timestamps directly from frames, which makes defining m
optional.New functions:
get_frametimes()
lets you extract the timestamps associated with each frame of a list of frames created using frames_spatial
or frames_graph
.Other improvements:
add_colourscale()
now calculates scale and legend with frame-wide fixed limits, when colours
is defined as a named vector, e.g. c("-1" = "red", "0" = "blue", "1" = "green")
.moveVis
now displays the approximated duration of an animation on the console, when creating frames or rendering frames.Bug fixes. Released on CRAN: 2019-04-11.
Bug fixes:
fade_raster = T
in frames_spatial()
due to unequal vector lengths returned by the internal interpolation function (issue #45)fade_raster = F
and/or r_times
contained time elements outside the time range covered by the timestamps of m
.
moveVis rewrite introducing a new logic and new functions. Released on CRAN: 2019-03-20
ggplot2
syntax can now be added to every single frame, allowing you to customize almost everything that can be customized using ggplot2
add_
functions wrapping pre-defined ggplot2
functions are included. For example, add_gg
offers dynamic overplotting, e.g. for polygons or points that change over timecolour
column in your movement data, allowing segmentation coulouring or colouring based on a logic, you defined beforhandggplot2
functionsext
argument of frames_spatial()
you can define user-defined area of interest (AOI), which scales the frame extent to a specific areamoveVis
supports Mapbox (free, registration needed). OpenStreetMap and Carto (both free) as base map services. See the manual of frames_spatial()
for details.frames_spatial()
now takes the argument equidistant
to define whether the map should be stretched to an equidistant (squared) extent (x and y axis representing same distance) or not (projection-native ratio).frames_spatial()
now uses coord_sf
to display projections (see details section of frames_spatial()
).align_move()
, get_maptypes()
, frames_spatial()
, frames_graph()
, add_gg()
, add_labels()
, add_scalebar()
, add_northarrow()
, add_progress()
, add_timestamps()
, add_text()
, add_colourscale()
, join_frames()
, suggest_formats()
, animate_frames()
: see the README and the description of the individual functions for further details.
subset_move()
: subset movement data for a particular time span
df2move()
: simple wrapper that converts data.frames into move or moveStack objects
view_spatial()
: view movement data on an interactive map using mapview
or leaflet
animate_move()
, animate_raster()
, animate_stats()
, get_formats()
, get_libraries()
: These functions have been replaced by a new logic and new functions.Reorganizing standard basemap usage by moveVis. Released on CRAN: 2018-11-23
map_type
are now retrieved from either OpenStreetMaps for thematic imagery or Microsoft Bing Maps for satellite/hybrid imagery. The usage of OpenStreetMaps is free. For intensive use of the Bing Maps basemap options, please provide your own Bing Maps API key through the api_key
argument, after registering at Microsoft here: https://msdn.microsoft.com/en-us/library/ff428642.aspx. Google Maps services will be implemented in a future update for restricted usage using an API key.map_type
: "satellite" (default), "hybrid", "roadmap", "roadmap_dark", "roadmap_bw", "roadmap_watercolor".map_zoom
for animate_move
: Increase or decrease the degree of detail of a static basemap.map_crop
for animate_move
: Define, if a static basemap should be cropped to the extent of m
or if a wider extent of optimal resolution should be used.Updating unit tests for CRAN checks. Released on CRAN: 2018-09-14
Windows library detection bugs fixed. Released on CRAN: 2018-09-07
time_pos_x
and time_pos_x
allow to specify the location of the timestamp displaytime_size
allows to specify the font size of the timestamp displayvideo support, automatic time harmonization, bug fixes. Released on CRAN: 2017-11-01
get_libraries()
– handles all extern libraries that are needed for video formats. Just run it to get information on what you need to install. Replaces get_imconvert(), which can still be called for code compatibility reasonsget_formats()
– outputs all file formats that can be used with moveVis depending on which libraries are installed on the system.adding frames_layout, static_data etc., improvements to workflow. Released on CRAN: 2017-08-20
adding animate_stats() and stats arguments for animate_move(). Released on CRAN: 2017-06-28
animate_stats()
– Enables creation of statistic plot animations visualizing possible relationships between movement paths and basemap. Define individual plot designs based on ggplot2 syntax.fixing major bug. Released on CRAN: 2017-06-28
adding frame_width and frame_height arguments. Released on CRAN: 2017-06-28
fixing important bug; adding animate_raster(). Released on CRAN: 2017-05-23
animate_raster()
– for animating just basemaps/for doing the same as with animate_move(), but without movement datainitial release. Released on CRAN: 2017-04-28
animate_move()
get_imconvert()
This document should provide a broad overview on changes that are applied to the moveVis R package. There is no warranty for completeness, since minor changes might not be included. All improvement and feature descriptions are bundled per release version. The document is currently maintained by Jakob Schwalb-Willmann.