if (requireNamespace("terra", quietly = TRUE) &&
terra_is_working() &&
requireNamespace("magick", quietly = TRUE)) {
tif_dir <- system.file("demo-geotiff", package = "snic", mustWork = TRUE)
files <- file.path(
tif_dir,
c(
"S2_20LMR_B02_20220630.tif",
"S2_20LMR_B04_20220630.tif",
"S2_20LMR_B08_20220630.tif",
"S2_20LMR_B12_20220630.tif"
)
)
s2 <- terra::aggregate(terra::rast(files), fact = 8)
set.seed(42)
seeds <- snic_grid(s2, type = "random", spacing = 10L, padding = 0L)
gif_file <- snic_animation(
s2,
seeds = seeds,
file_path = tempfile("snic-demo", fileext = ".gif"),
max_frames = 20L,
snic_args = list(compactness = 0.1),
r = 4, g = 3, b = 1,
device_args = list(height = 192, width = 256)
)
gif_file
}
Run the code above in your browser using DataLab