| relocate.Spat | R Documentation |
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.
## S3 method for class 'SpatRaster'
relocate(.data, ..., .before = NULL, .after = NULL)
## S3 method for class 'SpatVector'
relocate(.data, ..., .before = NULL, .after = NULL)
.data |
A |
... |
< |
.before, .after |
< |
A Spat* object of the same class than .data. See Methods.
terra::subset(data, c("name_layer", "name_other_layer"))
Implementation of the generic dplyr::relocate() function.
SpatRasterRelocate layers of a SpatRaster.
SpatVectorThe result is a SpatVector with the attributes on a different order.
dplyr::relocate()
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()
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())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.