powered by
SpatRaster
as_coordinates() can be used to obtain the position of each cell on the SpatRaster matrix.
as_coordinates()
as_coordinates(x, as.raster = FALSE)
A tibble or a SpatRaster (if as.raster = TRUE) with the same number of rows (or cells) than the number of cells in x.
tibble
as.raster = TRUE
x
When as.raster = TRUE the resulting SpatRaster has the same crs, extension and resolution than x
A SpatRaster object.
If TRUE, the result is a SpatRaster object with three layers indicating the position of each cell (cell number, row and column).
TRUE
slice.SpatRaster()
Coercing objects: as_sf(), as_spatraster(), as_spatvector(), as_tibble.Spat, fortify.Spat
as_sf()
as_spatraster()
as_spatvector()
as_tibble.Spat
fortify.Spat
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()
Run the code above in your browser using DataLab