raster_animation: Raster Animation

View source: R/raster_animation.R

raster_animationR Documentation

Raster Animation

Description

Raster Animation

Usage

raster_animation(
  rasters,
  filename,
  bbox,
  outdir,
  framerate = 4,
  width = 7,
  height,
  dpi = 100
)

Arguments

rasters

Any RasterStack

filename

The output filename with a video extension, such as mp4, mkv, mov, or flv. For more information visit av::av_encode_video()

bbox

A vector with four values corresponding to xmin, ymin, xmax, ymax

outdir

Output directory for storing video frames (graphics). The default is a temporary folder

framerate

A number of frames per seconds. For more information visit av::av_encode_video()

width

The width the plot. The default is 7 (inches). For more information visit tmap::tmap_save()

height

The height of the plot. The default value is calculated automatically based on the RasterStack dimensions

dpi

The default is 100. For more information visit tmap::tmap_save()

Value

A video file

Examples

 ## Not run: 
  Path <- "C:/Google Drive/Corvus Geostat - Jakub Nowosad/"
  Path <- "../corvus_dynamic_outputs/"
  input_file <- paste0(Path,"NetCDF/DxResults_Cc_2010-2015.nc")
  AllYears <- extract_data_list(input_file, "Weekly Growth Index",
                              years = 2000:2014)
  rasters <- create_raster_stack(AllYears, years = 2000:2014)

  # xmin, ymin, xmax, ymax
  world_bbox <- c(-180, -90, 180, 90)
  africa_bbox <- c(-17.8, -34.9, 51.2, 37.4)
  europe_bbox <- c(-32, 34, 70, 56)
  #

  # it takes about 8 minut for 780 frames
  # the below examples use only 60 frames to show an example
  rasters2 = raster::subset(rasters, 1:60)
  raster_animation(rasters = rasters2,
                   filename = "europe6.mp4",
                   bbox = europe_bbox)

  raster_animation(rasters = rasters2,
                   filename = "africa.mp4",
                   bbox = africa_bbox)

  raster_animation(rasters = rasters2,
                   filename = "world.mp4",
                   bbox = world_bbox)

## End(Not run)

aniaszy/ffipm documentation built on July 3, 2022, 2:40 a.m.