relocate.Spat {tidyterra} | R Documentation |
Change layer/attribute order
Description
Use relocate()
to change layer/attribute positions, using the same syntax
as select.Spat
to make it easy to move blocks of
layers/attributes at once.
Usage
## S3 method for class 'SpatRaster'
relocate(.data, ..., .before = NULL, .after = NULL)
## S3 method for class 'SpatVector'
relocate(.data, ..., .before = NULL, .after = NULL)
Arguments
.data |
A |
... |
< |
.before , .after |
< |
Value
A Spat*
object of the same class than .data
. See Methods.
terra equivalent
terra::subset(data, c("name_layer", "name_other_layer"))
Methods
Implementation of the generic dplyr::relocate()
function.
SpatRaster
Relocate layers of a SpatRaster
.
SpatVector
The result is a SpatVector
with the attributes on a different order.
See Also
Other dplyr verbs that operate on columns:
glimpse.Spat
,
mutate.Spat
,
pull.Spat
,
rename.Spat
,
select.Spat
Other dplyr methods:
arrange.SpatVector()
,
bind_cols.SpatVector
,
bind_rows.SpatVector
,
count.SpatVector()
,
distinct.SpatVector()
,
filter-joins.SpatVector
,
filter.Spat
,
glimpse.Spat
,
group-by.SpatVector
,
mutate-joins.SpatVector
,
mutate.Spat
,
pull.Spat
,
rename.Spat
,
rowwise.SpatVector()
,
select.Spat
,
slice.Spat
,
summarise.SpatVector()
Examples
library(terra)
f <- system.file("extdata/cyl_tile.tif", package = "tidyterra")
spatrast <- rast(f) %>% mutate(aa = 1, bb = 2, cc = 3)
names(spatrast)
spatrast %>%
relocate(bb, .before = cyl_tile_3) %>%
relocate(cyl_tile_1, .after = last_col())