Create a new Dataset object by automatically calculating all metadata from the underlying data. This function is useful when pre-calculated metadata are not available. Note this function will take longer to create variables than other functions because it requires performing geospatial operations.

new_dataset_from_auto(x, skip_bm = FALSE, id = uuid::UUIDgenerate())

Arguments

x

sf::st_sf() or raster::stack() object.

skip_bm

logical skip generating boundary data? (See details for more information)

id

character unique identifier. Defaults to a random identifier (uuid::UUIDgenerate()).

Value

A Dataset object.

Details

Create a new Dataset object.

For spatial uploads (shapefile) with many planning units, building boundary data can result in a std::bad_alloc error. To avoid this, the user can skip generating a boundary matrix by setting skip_bm = TRUE.

Examples

# find example data
f <- system.file(
  "extdata", "projects", "sim_raster", "sim_raster_spatial.tif",
  package = "wheretowork"
)

# import data
r <- suppressWarnings(raster::raster(f))
r <- raster::stack(r, r * 2, r * 3, r * 4)

# create new dataset
d <- new_dataset_from_auto(r)

# print object
print(d)
#> Dataset
#>   paths:
#>     spatial: memory
#>     attribute: memory
#>     boundary: memory