as_tibble | R Documentation |
Generate a data frame version of any raster object. Use the arguments 'cell', 'dim', 'split_date' and 'value' to control the columns that are included in the output.
## S3 method for class 'BasicRaster'
as_tibble(
x,
cell = TRUE,
dim = nlayers(x) > 1L,
value = TRUE,
split_date = FALSE,
xy = FALSE,
...
)
x |
a RasterLayer, RasterStack or RasterBrick |
cell |
logical to include explicit cell number |
dim |
logical to include slice index |
value |
logical to return the values as a column or not |
split_date |
logical to split date into components |
xy |
logical to include the x and y centre coordinate of each cell |
... |
unused |
If the raster has only one layer, the slice index is not added. Use 'dim = FALSE' to not include the slice index value.
a data frame (tibble) with columns:
cellvalue
the actual value of the raster cell
cellindex
the index of the cell (numbered from 1 to ncell()
in the raster way).
Columns cellindex
or cellvalue
may be omitted if either or both of cell
and/or value
are FALSE
, respectively
Other columns might be included depending on the properties of the raster and the arguments to the function:
year
,month
,day
if split_date
is TRUE
x
,y
if xy
is TRUE
dimindex
if the input has more than 1 layer and dim
is TRUE
.
## basic data frame version of a basic raster
as_tibble(raster::raster(volcano))
## data frame with time column since raster has that set
r <- raster::raster(volcano)
br <- raster::brick(r, r)
as_tibble(raster::setZ(br, Sys.Date() + 1:2), cell = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.