I have a list of rasters. I would like to create polygons based on the extent of each raster and combine all the newly made polygons into a single object.
I tried the following:
library(tidyverse)
library(raster)
library(sf)
lst(
raster(ext = extent(20, 21, 10, 11)),
raster(ext = extent(25, 26, 15, 16))
) %>%
map(
~ .x %>%
pluck("extent") %>%
as("SpatialPolygons")
) %>%
st_union()
but it throws an error because st_union
or st_combine
don't accept lists.
How can I combine a list of polygons into a multi-polygon object?