Travis-CI Build Status Coverage Status

mapmate (map animate) is an R package for map animation. It is used to generate and save a sequence of plots to disk as a still image sequence intended for later use in data animation production.

Install

devtools::install_github("leonawicz/mapmate")

This installs the current development version. Functionality is subject to change.

Example videos based on mapmate

Historical and projected global temperature anomalies

Global UAF/SNAP Shiny Apps web traffic

Flat map great circle animation example

Introduction and basic example

The mapmate package is used for map- and globe-based data animation pre-production. Specifically, mapmate functions are used to generate and save to disk a series of map graphics that make up a still image sequence, which can then be used in video editing and rendering software of the user’s choice. This package does not make simple animations directly within R, which can be done with packages like animation. mapmate is more specific to maps, hence the name, and particularly suited to 3D globe plots of the Earth. Functionality and fine-grain user control of inputs and outputs are limited in the current package version.

library(mapmate)
library(dplyr)
data(annualtemps)
annualtemps
#> # A tibble: 55,080 × 4
#>          lon      lat  Year     z
#>        <dbl>    <dbl> <int> <dbl>
#> 1  -176.6667 53.66633  2010  1.09
#> 2  -176.6667 66.99967  2010  3.21
#> 3  -176.6667 73.66633  2010  2.76
#> 4  -170.0000 53.66633  2010  0.91
#> 5  -170.0000 60.33300  2010  2.47
#> 6  -170.0000 66.99967  2010  2.73
#> 7  -163.3333 20.33300  2010  0.19
#> 8  -163.3333 53.66633  2010  0.79
#> 9  -163.3333 60.33300  2010  1.43
#> 10 -163.3333 66.99967  2010  1.28
#> # ... with 55,070 more rows

library(RColorBrewer)
pal <- rev(brewer.pal(11, "RdYlBu"))

temps <- mutate(annualtemps, frameID = Year - min(Year) + 1)
frame1 <- filter(temps, frameID == 1)  # subset to first frame
id <- "frameID"

save_map(frame1, z.name = "z", id = id, ortho = FALSE, col = pal, type = "maptiles",
    save.plot = FALSE, return.plot = TRUE)
save_map(frame1, z.name = "z", id = id, col = pal, type = "maptiles", save.plot = FALSE,
    return.plot = TRUE)

2D flat map and 3D globe2D flat map and 3D globe

The above is only a very basic initial example of static 2D and 3D maps. See the introduction vignette for more complete and more typical usage examples:

browseVignettes(package = "mapmate")

Other features and functionality will be added in future package versions.

How Earth perspective view works in mapmate

This application shows how longitude, latitude, and rotation axis are used by the save_map function in mapmate to define the hemispheric field of view for the Earth. These three values define an arbitrary perspective. Longitude and latitude specify the centroid coordinates for the visible hemisphere and the angle given for the rotation axis is used to rotate the circle in the viewing plane. The save_map argument defaults for lon, lat, and rotation.axis are (0, 0, 23.4), respectively.

Direct link to app