Either create file path for saving a cube or parse the meta data from a cube
name_env_tif(
x,
dir_only = FALSE,
skips = c("base"),
prefixes = c("sat", "use"),
file_type = c("\\.tif", "\\.nc"),
parse = FALSE,
fill_null = FALSE,
x_null = 3,
...,
context_defn = c("polygons", "filt_col", "level", "buffer"),
cube_defn = c("period", "res"),
source_defn = c("source", "collection"),
layer_defn = c("layer", "start_date", "file_type"),
make_name = TRUE
)
Either dataframe with path(s) to parse (in column path
), character
vector of path(s) to search, or named list.
Logical. Are full file paths provided (or required) or just a directory?
Character. When parsing, skip (filter) any files with a match to skips
Character. If x is a named list, any name prefixes to remove before matching to naming structure.
Character. e.g. "tif". More than one can be provided but if
parse
then file_type[1]
is used for out_file
file type.
Logical. If FALSE
an out_file
path will be returned rather
than parsed. Assumes the appropriately names columns are supplied in df
.
Logical. If TRUE
, will fill up to x_null
definitions
with NULL (and issue a warning).
Numeric. Even if fill_null
is TRUE
, if there are more than
x_null
missing definitions, an error will be thrown.
Logical. If TRUE a column 'name' will be added to the output in a format suitable for use in model formulas.
If !parse
, tibble with (default) columns:
Vector layer originally used to define area of interest
Column name from vector to filter to define area of interest
Level(s) of filt_col originally filtered to define area of interest
Any buffer around area of interest
Period represented within layer using ISO8601-compliant time period for regular data cubes. e.g., "P16D" for 16 days
Resolution of output raster in units of rasters crs
e.g. DEA
is digital earth Austrlia
e.g. ga_ls8c_ard_3
is landsat 8 collection in DEA
Band or layer name
Start date for layer
File type of path
.
Full (relative) path including file_type
.
A name that should be safe to use in model formulas:
paste0(layer, "__", gsub("-", "",start_date))
If !parse
, df
with additional column out_file
#library(envRaster)
out_dir <- file.path(system.file(package = "envRaster"), "examples")
cube_dir <- fs::path(out_dir, "cube")
settings <- list()
# cube setup
## geographic extent
settings$polygons <- "aoi"
settings$filt_col <- NULL
settings$level <- NULL
settings$buffer <- 0
# can be used in envFunc::make_aoi
## grain size
settings$period <- "P3M"
settings$sat_res <- 90
## source
settings$source <- "DEA"
settings$collection <- c("ga_ls9c_ard_3", "ga_ls8c_ard_3")
## directory
settings$out_dir <- fs::path(cube_dir
, name_env_tif(settings
, fill_null = TRUE
, dir_only = TRUE
)$out_dir
)
#> Warning: All of filt_col and level will be NULL
fs::dir_create(settings$out_dir)
# save settings
rio::export(settings
, fs::path(cube_dir, "settings.rds")
)
# go and make cube. e.g. examples in ?get_sat_data()
tifs <- length(fs::dir_ls(settings$out_dir, regexp = "tif$"))
if(!tifs) {
source(fs::path(out_dir, "get_sat_data_ex.R"))
}
name_env_tif(settings$out_dir
, parse = TRUE
)
#> # A tibble: 4 × 13
#> polygons filt_col level buffer period res source collection layer start_date
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 aoi "" "" 0 P3M 90 DEA ga_ls9c_a… ndvi 2022-12-01
#> 2 aoi "" "" 0 P3M 90 DEA ga_ls9c_a… ndvi 2023-03-01
#> 3 aoi "" "" 0 P3M 90 DEA ga_ls9c_a… ndvi 2023-06-01
#> 4 aoi "" "" 0 P3M 90 DEA ga_ls9c_a… ndvi 2023-09-01
#> # ℹ 3 more variables: file_type <chr>, name <chr>, path <chr>