Skip to contents

This is a convenience function that allows users to easily convert a plain list of SpatRasters to a PackedSpatRaster_list. It will check that all elements of the list are SpatRasters and then wrap them as PackedSpatRasters before creating the PackedSpatRaster_list. If the input is already a PackedSpatRaster_list, it will simply return it unchanged.

Usage

as_PackedSpatRaster_list(x)

Arguments

x

A list of SpatRasters or a PackedSpatRaster_list.

Value

A PackedSpatRaster_list.

Examples

r1 <- terra::rast(nrows = 4, ncols = 4, vals = 1:16, crs = "EPSG:4326")
r2 <- terra::rast(nrows = 4, ncols = 4, vals = rnorm(16))
lst <- list(r1, r2)
pl <- as_PackedSpatRaster_list(lst)