reg <- bf_registry(name = "testBF", description = "test bitfield",
template = bf_tbl)
reg <- bf_map(protocol = "na", data = bf_tbl, registry = reg, x = y)
field <- bf_encode(registry = reg)
# with raster data
library(terra)
bf_rst <- rast(nrows = 3, ncols = 3, vals = bf_tbl$commodity, names = "commodity")
bf_rst$yield <- rast(nrows = 3, ncols = 3, vals = bf_tbl$yield)
reg <- bf_registry(name = "testBF", description = "raster bitfield",
template = bf_rst)
reg <- bf_map(protocol = "na", data = bf_rst, registry = reg, x = commodity)
field <- bf_encode(registry = reg) # returns a SpatRaster
Run the code above in your browser using DataLab