as_coordinates {tidyterra} | R Documentation |
Get cell number, row and column from a SpatRaster
Description
as_coordinates()
can be used to obtain the position of each cell on the
SpatRaster
matrix.
Usage
as_coordinates(x, as.raster = FALSE)
Arguments
x |
A |
as.raster |
If |
Value
A tibble
or a SpatRaster
(if as.raster = TRUE
) with
the same number of rows (or cells) than the number of cells in x
.
When as.raster = TRUE
the resulting SpatRaster
has the same crs,
extension and resolution than x
See Also
Coercing objects:
as_sf()
,
as_spatraster()
,
as_spatvector()
,
as_tibble.Spat
,
fortify.Spat
Examples
library(terra)
f <- system.file("extdata/cyl_temp.tif", package = "tidyterra")
r <- rast(f)
as_coordinates(r)
as_coordinates(r, as.raster = TRUE)
as_coordinates(r, as.raster = TRUE) %>% plot()
[Package tidyterra version 0.6.1 Index]