GithubHelp home page GithubHelp logo

Comments (2)

brownag avatar brownag commented on June 1, 2024

Hi @Christopher-Blackford

I am guessing you may be using Whitebox via the R package based on the syntax/function names

when I don’t specify the argument, the output rasters seem to lineup to the compress_rasters=TRUE output

I think this is because WhiteboxTools ships with a settings.json file that sets compress_rasters=TRUE. The R package behavior is to not add most "missing" arguments. This is to allow users to utilize settings.json and package options to control these settings (verbosity, working directory, compression, cores).

You can set the R package up to automatically supply --compress_rasters=FALSE (and update settings.json) by calling wbt_compress_rasters(FALSE)

The documentation for the R package and the default values of arguments would suggest that some tools have FALSE as default, but ultimately if the argument is not passed to the R function then it is not considered in constructing the command, so Whitebox then uses values existing in settings.json.

While there is some documentation of this behavior in the R package, the individual functions do not reference the possibility that their defaults may be overridden by other settings. I have recently been thinking about some ways to improve the R package documentation detail, and some better explanation about how arguments to functions v.s. whiteboxtools options may be warranted there. If you are having issues with the R documentation, could you please post an issue on that repository? https://github.com/opengeos/whiteboxR/issues/

Consider this example:

library(whitebox)

settings_json <- file.path(dirname(wbt_exe_path(shell_quote = FALSE)), "settings.json")
file.remove(settings_json)
#> [1] TRUE

# fresh install of whitebox
install_whitebox()
#> Performing one-time download of WhiteboxTools binary from
#>   https://www.whiteboxgeo.com/WBT_Linux/WhiteboxTools_linux_amd64.zip 
#> (This could take a few minutes, please be patient...)
#> WhiteboxTools binary is located here:  /home/andrew/.local/share/R/whitebox/WBT/whitebox_tools 
#> You can now start using whitebox
#>     library(whitebox)
#>     wbt_version()

# default compress_rasters=TRUE
settings_json |> 
  jsonlite::read_json()
#> $verbose_mode
#> [1] TRUE
#> 
#> $working_directory
#> [1] ""
#> 
#> $compress_rasters
#> [1] TRUE
#> 
#> $max_procs
#> [1] -1

wbt_slope(sample_dem_data(), "before.tif")

# set R package to pass --compress_rasters=FALSE
wbt_compress_rasters(FALSE)

wbt_slope(sample_dem_data(), "after.tif")


# now "after.tif" is not compressed, and no compress_rasters argument is passed to wbt_slope()

file.size("before.tif")
#> [1] 171274
file.size("after.tif")
#> [1] 180172

# as wbt_slope runs with the new compress_rasters option, the settings.json file is updated
settings_json |> 
  jsonlite::read_json()
#> $verbose_mode
#> [1] TRUE
#> 
#> $working_directory
#> [1] ""
#> 
#> $compress_rasters
#> [1] FALSE
#> 
#> $max_procs
#> [1] -1

from whitebox-tools.

Christopher-Blackford avatar Christopher-Blackford commented on June 1, 2024

Thanks @brownag, I'll take a look at the json settings. You are correct, I was using the R package for whiteboxtools. Apologies for posting in the general repository, if I have any follow ups I'll follow up in the whiteboxR repo

from whitebox-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.