Learn R Programming

terra (version 1.9-25)

animate: Animate a map

Description

Animate (sequentially plot) the layers of a SpatRaster, or a SpatVectorCollection, or the variables or geometries of a SpatVector, to create a movie.

Usage

# S4 method for SpatRaster
animate(x, pause=0.25, main, range=NULL, maxcell=50000, n=1, ...)

# S4 method for SpatVector animate(x, pause=0.25, main="", n=1, vars=NULL, range=NULL, add=NULL, ...)

# S4 method for SpatVectorCollection animate(x, pause=0.25, n=1, vars=NULL, range=NULL, ext=NULL, add=NULL, ...)

Arguments

Value

None

See Also

Examples

Run this code
r <- rast(system.file("ex/logo.tif", package="terra"))   
animate(r, n=1)

v <- vect(system.file("ex/lux.shp", package="terra"))
animate(v[1:3, ], n=1, pause=0.3)
# animate(v, vars=names(v))

s <- svc(as.lines(v[3:5,]), v, v[1:3,], as.points(v))
animate(s, col="blue", alpha=0.3, pause=0.3)

# you can save an animation to file like this
# animation::saveGIF(terra::animate(v), "animation.gif")

Run the code above in your browser using DataLab