17  Animations

library(sf)
#> Linking to GEOS 3.13.0, GDAL 3.10.3, PROJ 9.6.0; sf_use_s2() is TRUE
library(tmap)
slo_borders = read_sf("data/slovenia/slo_border.gpkg")
slo_regions_ts = read_sf("data/slovenia/slo_regions_ts.gpkg")

17.1 Creating animations

tm_shape(slo_borders) +
  tm_borders() +
  tm_shape(slo_regions_ts) +
  tm_polygons("gdppercap") +
  tm_animate(by = "time")

17.2 Saving animations

tma1 = tm_shape(slo_borders) +
  tm_borders() +
  tm_shape(slo_regions_ts) +
  tm_polygons("gdppercap") +
  tm_animate(by = "time")
tmap_animation(tma1, "tma1.gif")