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.
Figure 1: Exemplary movement tracks nearby Lake of Constance on top of a OSM watercolor and a mapbox satellite base map
Figure 2: Exemplary movement tracks nearby Lake of Constance and a gradient base layer faded over time
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.0 is not on CRAN yet (but will be soon). Until then, to install moveVis
version 0.10.0, run:
devtools::install_github("16EAGLE/moveVis")
Code written for moveVis
version <=0.9.9 will not work with the 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 adata.frame
into amove
ormoveStack
object. This is useful if you do not usually work with themove
classes and your tracks are present asdata.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 amove
ormoveStack
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 withframes_spatial()
.moveVis
supports OpenStreetMaps and Mapbox basemap imergay. Alternatively, you can provide custom imagery toframes_spatial()
.frames_spatial()
creates a list ofggplot2
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 usinganimate_frames()
.frames_graph()
creates a list ofggplot2
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 usinganimate_frames()
.
add_gg()
addsggplot2
functions (e.g. to add layers such as points, polygons, lines, or to change scales etc.) to the animation frames created withframes_spatial()
orframes_graph()
. Instead of creating your ownggplot2
functions, you can use one of the othermoveVis
`add_``functions:add_labels()
adds character labels such as title or axis labels to animation frames created withframes_spatial()
orframes_graph()
.add_scalebar()
adds a scalebar to the animation frames created withframes_spatial()
orframes_graph()
.add_northarrow()
adds a north arrow to the animation frames created withframes_spatial()
orframes_graph()
.add_progress()
adds a progress bar to animation frames created withframes_spatial()
orframes_graph()
.add_timestamps()
adds timestamps to animation frames created withframes_spatial()
orframes_graph()
.add_text()
adds static or dynamically changing text to the animation frames created withframes_spatial()
orframes_graph()
.add_colourscale()
adjusts the colour scales of the animation frames created withframes_spatial()
and custom map imagery using ther_list
argument.join_frames()
side-by-side joins theggplot2
objects of two or more frames lists of equal lengths into a single list ofggplot2
objects per frame usingcowplot::plot_grid
. This is useful if you want to side-by-side combine spatial frames returned byframes_spatial()
with graph frames returned byframes_graph()
.
suggest_formats()
returns a selection of suggested file formats that can be used without_file
ofanimate_frames()
on your system.animate_frames()
creates an animation from a list of frames computed withframes_spatial()
,frames_graph()
orjoin_frames()
.
view_spatial()
displays movement tracks on an interactivemapview
orleaflet
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)
data("move_data") # move class object
# if your tracks are present as data.frames, see df2move() for conversion
# align move_data to a uniform time scale
move_data <- align_move(move_data, res = 240, digit = 0, unit = "secs")
# create spatial frames with a OpenStreetMap watercolour map
frames <- frames_spatial(move_data, path_colours = c("red", "green", "blue"),
map_service = "osm", map_type = "watercolor", alpha = 0.5)
frames[[100]] # preview one of the frames
# animate frames
animate_frames(frames, out_file = "/full/path/to/example_1.gif")
You can find detailed 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
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:
- "keep tracks" setting to force paths to not disappear
- follow population mode
- follow individual mode
- day-/night-time visualization
Some day:
- 3D animations, e.g. for including altitude data
The Department of Remote Sensing of the University of Würzburg has developed other R packages that might interest you:
- 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.
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.