I have a time series of 25 yearly land cover rasters. As this is categorical data, I use levelplot(inputRaster)
(part of the rasterVis library) to plot a single raster. However, I would like to sequentially plot the yearly rasters, as the animate
function of the raster library does. When I use
rasStack <- stack(listOfRasters)
animate(rasStack)
The result does not have a categorical legend.
So in short: how can I combine the functionalities of levelplot
and animate
?
Function
animate
only accepts raster objects as input. You can trysaveGIF
to animate levelplots: