select.SpatRaster | R Documentation |
This function allows you to select specific layers from a SpatRaster object using tidyverse-style syntax similar to dplyr's select. Supports selection by name, position, and tidyselect helpers.
## S3 method for class 'SpatRaster'
select(.data, ...)
.data |
A SpatRaster object containing multiple layers |
... |
Expressions for selecting layers. You can use:
|
A SpatRaster object containing only the selected layers
## Not run:
library(terra)
r <- rast(c("elevation.tif", "slope.tif", "aspect.tif"))
# Select by name
r_elev <- select(r, elevation)
# Select multiple layers
r_sub <- select(r, elevation, slope)
# Exclude layers with negative selection
r_no_aspect <- select(r, -aspect)
# Use tidyselect helpers
r_s <- select(r, starts_with("s"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.