wbt_file_path: Prepare File Paths for WhiteboxTools Commands

View source: R/wbt.R

wbt_file_pathR Documentation

Prepare File Paths for WhiteboxTools Commands

Description

Performs path expansion with path.expand() and shell quotes with shQuote() the input paths.

Usage

wbt_file_path(x, shell_quote = TRUE, delimiter = ",", check_exists = FALSE)

Arguments

x

character or terra object. Vector of file paths or strings of file paths for passing as arguments to WhiteboxTools. If the object is of class SpatRaster, SpatRasterCollection, SpatVector or SpatVectorProxy the sources are extracted with terra::sources()

shell_quote

logical. Shell quotes around result? Default: TRUE

delimiter

character. Either "," (default) or ";" allowed by WhiteboxTools.

check_exists

logical. Check if file(s) in x exist? Useful for input values. Default: FALSE

Details

If an input vector contains ";" or "," this is considered, path expansion is performed on the substrings. If the input vector has length greater than 1, the vector is concatenated with "," or ";" to create a single output string.

Value

character. Length 1. A safe input string for use in WhiteboxTools commands, with paths expanded and concatenated, if necessary, and optionally shell quoted.

Examples


wbt_file_path("./abc.tif")

wbt_file_path("./abc.tif;./def.tif")

wbt_file_path("./abc.tif,./def.tif")

wbt_file_path(c("./abc.tif", "./def.tif"))

wbt_file_path("~/abc.tif", shell_quote = FALSE)

wbt_file_path(c("~/abc.tif", "~/def.tif"))


whitebox documentation built on Nov. 19, 2023, 1:07 a.m.