misc/introduce-wbt.md

Add wbt_result class, and wbt() pipelines

The current way of invoking system() is not the most forgiving when it comes to syntax errors or misspecification of arguments. Often users are met with something unpleasant in the form of a Rust backtrace if their input led to an incomplete or incorrectly parsed system() call.

On top of that, many R users are accustomed to working with raster/vector data in one or more of the "spatial" data packages. A key benefit of using R as a spatial data analysis environment is powerful linkages between tools. Better integration of whitebox with user package preferences and project specific parameters (such as Coordinate Reference System transformations, batch processing) would provide added benefit to R users.

I have proposed an alternate approach to this with new S3 method: wbt(). This is not necessarily a replacement for the hard-coded option, but showing some of the above benefits that come from working with tool metadata to provide a more generic interface.

I have provisionally defined the following wbt() methods:

wbt() works a lot like wbt_run_tool() where you specify a tool name to run; except it uses non-standard evaluation to provide tool parameter input. wbt.character() is the main interface to getting started with these methods. It just takes a tool name as a character, or an expression that can be substituted and deparsed to a tool name.

The wbt() methods return a value that inherits a "new" S3 class "wbt_result" (just a list()). This stores information about the inputs and arguments to WhiteboxTools. It can contain errors and information about the results

An added feature is that wbt() method can take a wbt_result as input.

The wbt.function() allows for non-standard evaluation of expressions such as wbt(wbt_breach_depressions, ...) which can be particularly handy for auto-complete in GUI like RStudio, but relies on that function being defined in the package. I am not sure that the benefits outweigh the complexities here as the function wbt_breach_depressions() is not called by wbt(), it is used in name only to build a call for wbt_run_tool().



giswqs/whiteboxR documentation built on Feb. 13, 2024, 6:16 p.m.