Learn R Programming

tabularaster (version 0.5.0)

as_tibble: Convert a Raster to a data frame.

Description

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.

Usage

# S3 method for BasicRaster
as_tibble(x, cell = TRUE, dim = nlayers(x) > 1L,
  value = TRUE, split_date = FALSE, xy = FALSE, ...)

Arguments

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

Value

a data frame ('tbl_df'/'tibble' form)

Details

If the raster has only one layer, the slice index is not added. Use 'dim = FALSE' to not include the slice index value.

Examples

Run this code
# NOT RUN {
#library(tabularaster)
#library(tibble)
#as_tibble(raster::raster(volcano))
#as_tibble(raster::setZ(raster::raster(volcano), Sys.Date()), cell = TRUE)
# }

Run the code above in your browser using DataLab