Assess whether a list of extents are all equal
equalExtent(extents)
# S4 method for list
equalExtent(extents)
list of extents objects
library(terra)
files <- system.file("maps", package = "quickPlot")
files <- dir(files, full.names = TRUE, pattern = "tif")
maps <- lapply(files, function(x) terra::rast(x))
names(maps) <- sapply(basename(files), function(x) {
strsplit(x, split = "\\.")[[1]][1]
})
extnts <- lapply(maps, terra::ext)
equalExtent(extnts) ## TRUE
#> [1] TRUE