Learn R Programming

greenSD (version 0.1.1)

to_gif: Convert A Multi-layer Raster to GIF

Description

Export a multi-layer raster (SpatRaster) or vector layer (sf) with multiple numeric value columns to an animated GIF.

Usage

to_gif(
  r,
  fps = 5,
  width = 600,
  height = 600,
  axes = TRUE,
  title_prefix = NULL,
  border = FALSE
)

Value

An animated magick image object (GIF).

Arguments

r

SpatRaster or sf. A SpatRaster with multiple layers or an sf object with multiple numeric value columns.

fps

numeric. Frames per second (default 5).

width

numeric. Width of output GIF in pixels.

height

numeric. Height of output GIF in pixels.

axes

logical. Draw axes?

title_prefix

character or character vector.

border

character. Color of polygon border(s); using NA hides them. Only optional when r is an sf object.

Examples

Run this code
sample_data <- terra::rast(system.file("extdata", "detroit_gs.tif", package = "greenSD"))
gif <- to_gif(sample_data)

Run the code above in your browser using DataLab