Learn R Programming

mptools (version 1.0.1)

mp_animate: Animate the output of a RAMAS Metapop simulation.

Description

Animate temporal habitat and abundance dynamics on a gridded landscape.

Usage

mp_animate(dat, habitat, outfile, zlim, axes = FALSE, col.regions = NULL, pt.col = NULL, pt.cex = 1, height = 800, width = 800, interval = 0.05, label = TRUE, label.pos = c(0.98, 0.05), label.just = "right", label.cex = 1.5, label.font = 2, overwrite = FALSE)

Arguments

dat
A SpatialPointsDataFrame object returned by mp2xy.
habitat
A RasterStack or RasterBrick object. The number of Raster layers should equal the number of simulation time steps. Further, the layers should be ordered temporally, and should correspond to the levels of dat$time. It is assumed that the time step between layers is consistent (i.e., the interval between animation frames is constant).
outfile
A character string giving the desired output path and filename.
zlim
A numeric vector of length 2 giving the lower and upper limits of the color scale indicating habitat quality. If this is not provided, a pretty range will be calculated (though this will impact efficiency).
axes
Logical. Should axes be drawn?
col.regions
A colorRampPalette function that will be used to generate the colour ramp for grids. If NULL, a default colour ramp based on terrain.colors is used.
pt.col
A colorRampPalette function that will be used to generate the colour ramp for points. These colours will be interpolated into 100 colours, which indicate relative mean population size, ranging from 1 (first element of the colour ramp) to the maximum mean population size that exists in the simulation output. If NULL, a default colour ramp ranging from white to black is used.
pt.cex
Point size magnifier, relative to the default.
height
Numeric. The height of the animation, in pixels. Default is 800.
width
Numeric. The width of the animation, in pixels. Default is 800.
interval
The time interval of the animation, in seconds. Default is 0.05, i.e. 20 frames per second.
label
Should a time step counter be plotted?
label.pos
A vector of two numbers giving the normalised parent coordinates at which the time step counter will be plotted. The first number gives the x-coordinate (0 = left edge, 1 = right edge) and the second gives the y-coordinate (0 = bottom edge, 1 = top edge). The default value of c(0.98, 0.05) plots the label at the bottom right corner. Ignored if label is FALSE.
label.just
Justification of the time step counter label, relative to label.pos. See the description of just at grid.text. Ignored if label is FALSE.
label.cex
Size of the time step counter text. Ignored if label is FALSE.
label.font
Font face of the time step counter text. See fontface at gpar for available options. Ignored if label is FALSE.
overwrite
Should outfile be overwritten if it already exists?

Value

NULL. The animation is saved as an animated .gif file at the specified path (outfile).

Details

mp_animate requires that either http://www.imagemagick.org or http://www.graphicsmagick.org are installed on the system. See the documentation for animation::im.convert for further details. An animated gif is created, with points indicating the location of populations with mean abundance greater than zero, overlaid upon a raster grid indicating habitat suitability. Relative population size is represented by point colour, with white corresponding to a population with mean abundance between 0 and 1 populations and time steps, and black corresponding to the maximum mean abundance. Colours for intermediate values are scaled linearly. The colour key indicates carrying capacity, and corresponds to the colour of grid cells. An example of this function's use is provided in the vignette "Introduction to mptools" (vignette('intro', 'mptools')).

See Also

mp2sp