Skip to contents

Looks name up in the catalogue and reads the layer's data file with terra. Rasters are returned as a SpatRaster, vectors as a SpatVector. When a folder holds more than one data file, pass file to choose; otherwise the ambiguity is reported along with the available files.

Usage

get_layer(name, file = NULL, return_path = FALSE, ...)

Arguments

name

Character; a layer name ("fab_dem") or catalogue id ("elevation/fab_dem") as listed by list_layers().

file

Optional character; a file name or regular expression selecting one file within the layer folder.

return_path

Logical; if TRUE, return the file path instead of reading the data. Default FALSE.

...

Passed to build_catalogue().

Value

A SpatRaster, a SpatVector, or a character path.

See also

layer_files() to see what a layer folder holds, layer_meta() for its metadata.

Examples

if (FALSE) { # \dontrun{
r <- get_layer("topographic_wetness_index")
p <- get_layer("fab_dem", return_path = TRUE)
g <- get_layer("grassland_inventory", file = "alberta")
} # }