animate_raster animates raster data provided as list of raster class objects. The function creates an animated GIF or video file and saves it into the output directory.

animate_raster(layer, out_dir, conv_dir = "convert", layer_dt = NULL,
  layer_type = "gradient", layer_stretch = "none",
  layer_col = c("sandybrown", "white", "darkgreen"), layer_nacol = "white",
  ...)

Arguments

layer

list. List of raster objects.

out_dir

character. Output directory of the output file.

conv_dir

character. Command of or path to required image/video converter tool. Depends on, what is specified for out_format. If out_format = "gif", animate_move() works with the ImageMagick convert tool. In this case, specify command of or path to the convert tool. You can use get_libraries to find or download/install convert. If out_format is a video format (e.g. "mp4", "mov" ...), animate_move() works with either the FFmpeg ffmepg tool or the libav avconv tool. In this case, specify command of or path to the ffmpeg or avconv tool. See also get_libraries. If not specified, animate_move() trys to find libraries automatically.

layer_dt

POSIXct or vector. Optional vector of POSIXct date/time stamps corresponding to the acquisition dates of the layer raster objects to display a time scale.

layer_type

charachter. Layer type. Either "RGB" (if layer is a rasterBrick class onejct), "gradient" or "discrete". Default is "RGB". Ignored, if layer = "basemap".

layer_stretch

character. Ignored, if layer_type is not "RGB". Either "none", "lin", "hist", "sqrt" or "log" for no stretch, linear, histogram, square-root or logarithmic stretch. Default is "none".

layer_col

character vector. Two or more colours to be used for displaying the background layer. If layer_type = "gradient", a colour ramp between the colous is calcualted. If layer_type = "discrete", the colours will be used per value range. Ignored, if layer_type = "RGB".

layer_nacol

character. Colour to be displayed for NA values. Default is "white".

...

additional arguments, see animate_move.

Value

None or logical (see log_logical). The output GIF or video file is written to the ouput directory.

Details

animate_raster is based on ggplot2. Depending on the selected output format (out_format, it either needs the convert tool of the ImageMagick software package (.gif format) or either ffmpeg from FFmpeg or avconv from libav (video formats). The command or directory to the convert tool needs to be provided with conv_dir. Please use get_libraries to search for the needed libraries and command/tool directories on your system or to automatically download and install the required software. See get_libraries and out_format and conv_dir for details.

See also

Examples

# NOT RUN {
#Create a list of several raster objects to be displayed one after another
#If layer_type = RGB, use a brick class obejct with RGB bands!
data("basemap_data") #example MODIS dataset
layer <- basemap_data[[1]] #list of rasters

#Get your convert directory/command
conv_dir <- get_libraries()

#Specify the output directory, e.g.
out_dir <- "/out/test"

#Call animate_raster
animate_raster(layer,out_dir = out_dir, conv_dir = conv_dir, layer_type = "gradient",
               out_format = "gif")

#use another file format for longer videos
animate_raster(layer,out_dir = out_dir, conv_dir = conv_dir, layer_type = "gradient",
               out_format = "mov")
# }