opengeos / whiteboxR

WhiteboxTools R Frontend
https://whiteboxR.gishub.org
Other
168 stars 30 forks source link

Error while runnig whitebox #89

Closed ejjunju closed 1 year ago

ejjunju commented 1 year ago

I have installed whitebox. The exe is available and the initiation returns TRUE but running operations, even on test data gives an error.

system(exeargs, intern = TRUE, ignore.stderr = ignore.stderr, :

Any tool i choose returns this error. see example

wbt_feature_preserving_smoothing(
     dem = dem,
     output = "./smoothed.tif",
     filter = 9
 )
feature_preserving_smoothing - Error in system(exeargs, intern = TRUE, ignore.stderr = ignore.stderr,  : 
  'CreateProcess' failed to run 'C:\Users\ejj\AppData\Local\R\WIN-LI~1\4.2\whitebox\WBT\WHITEB~1.EXE --run=FeaturePreservingSmoothing  --dem="C:/WORK/KOMPETANSEUTVIKLING/R/Catchment_delineation/uganda_hydrosheds_af_con_3s.tif" --output="./smoothed.tif" --filter=9 --norm_diff=15 --num_iter=3 --max_diff=0.5 -v'
brownag commented 1 year ago

Hi, it looks like the path to your whitebox executable is getting shortened to "8.3" style file names. (C:\Users\ejj\AppData\Local\R\WIN-LI~1\4.2\whitebox\WBT\WHITEB~1.EXE)

This is an unfortunate side effect of system() calls involving longer paths on Windows. The WhiteboxTools command line tool does not work with this abbreviated name for the whitebox executable (WHITEB~1.EXE) because the name "whitebox_tools" is hard-coded in the part of the tool that parses the command line options--so there is nothing I can do in the R package to fix this, short of changing the way system calls are made to use something like {processx}... which I am not inclined to do for a few reasons.

Here is a report of this issue from when I identified it : https://github.com/jblindsay/whitebox-tools/issues/190

A work-around is to install the binary in a shorter directory path location... something like:

whitebox::install_whitebox(pkg_dir="C:/whitebox")

You will then want to set e.g. wbt_init(exe_path="C:/whitebox/WBT/whitebox_tools.exe") in later sessions or use an environment variable R_WHITEBOX_EXE_PATH to point to this installation location

brownag commented 1 year ago

This might actually be different from the issue I linked to above, perhaps you don't have permissions to run an executable in that directory? Nonetheless installing somewhere else that you do have permissions (e.g. Program Files folder) might to the trick.

brownag commented 1 year ago

Closing this due to inactivity. If you are still having trouble please feel free to open a new issue.