animate_maps | R Documentation |
plot_territories
or plot_forage_density
This function generates an animation between map time steps to visualise change over time using the magick package.
animate_maps(
map_list,
filename = NULL,
x_pix = 1200,
y_pix = 675,
pix_res = 96,
n_frames = 10,
fps = 5
)
map_list |
A list of ggplot objects generated with either |
filename |
character string for the save path if saving to disk is required. |
x_pix |
numeric denoting width of the animation canvas in pixels |
y_pix |
numeric denoting height of the animation canvas in pixels |
pix_res |
numeric denoting canvas resolution |
n_frames |
numeric for the number of frames to use for transitions |
fps |
numeric for the number of frames per second for the resulting animation |
Animated map of esither territory locations over time or feeding density over time.
## Not run:
# kde plots for panel/animation
fsd_ggplot <- function(.data, p.names, p.ext, add_map_stuff= FALSE){
if (isTRUE(add_map_stuff)){
fsd <- plot_forage_density(.data, guide = FALSE, catchment = RivOtter_Catch_Area,
rivers = TRUE, plot_extent = p.ext, axes_units = FALSE) +
ggplot2::labs(subtitle = sprintf('Beaver Foraging Density: %s', p.names))
} else {
fsd <- plot_forage_density(.data, axes_units = FALSE, north_arrow = FALSE, scalebar = FALSE, guide = FALSE,
catchment = RivOtter_Catch_Area, rivers = TRUE, plot_extent = p.ext) +
ggplot2::labs(subtitle = p.names)
}
return(fsd)
}
# get name list for plots
plot_names <- unique(RivOtter_FeedSigns$SurveySeason)
ras_ext <- inflate_bbox(RivOtter_FeedSigns, 250)
# generate KDE rasters for all survey periods
kde_ras_list <- RivOtter_FeedSigns %>%
dplyr::group_by(SurveySeason) %>%
dplyr::group_map(., ~forage_density(., 'FeedCat', kd_extent = ras_ext))
# animate kernel density rasters
kde_animation <- kde_ras_list %>%
purrr::map2(.x=., .y=plot_names, ~fsd_ggplot(.x, .y, inflate_bbox(RivOtter_Catch_Area, 200),
add_map_stuff = TRUE)) %>%
animate_maps(.)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.