opengeos / whiteboxR

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

Whitebox will not run any tools with error thread 'main' panicked #62

Closed EmFidan closed 2 years ago

EmFidan commented 2 years ago

I have been using WhiteBox through the R interface for a while now. I haven't had any issues with running wbt functions before, except this week. I have been trying to run simple DEM processing and watershed commands such as:

watersheds_r <- wbt_watershed(d8_pntr = "~/Desktop/NC_Processed_Geospatial_Data/Elevation/FlowDir_D8.tif", 
pour_pts = "~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/snapped_pour_points.shp", 
output = "~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/watersheds.tif")

The error I have been receiving is:

thread 'main' panicked at 'No such file or directory (os error 2)', whitebox-tools-app/src/main.rs:72:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Error running WhiteboxTools (watershed)
  whitebox.exe_path: '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/whitebox/WBT/whitebox_tools'; File exists? TRUE
  Arguments: --run=watershed  --d8_pntr=~/Desktop/NC_Processed_Geospatial_Data/Elevation/FlowDir_D8.tif --pour_pts=~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/snapped_pour_points.shp --output=~/Desktop/Projects/Flood_WQ_Modeling/Data/GIS/R_Outputs/watersheds.tif -v

System command had status 101
watershed - Elapsed Time: NA [did not run]

I have the executable files present, thanks to the install_whitebox function, and I have trying to debug with no luck. The DEM is pretty large but I used Whitebox tools to previously process this same DEM with no issues. Any ideas what might be causing this?

brownag commented 2 years ago

I think the issue is use of ~ to refer to your home directory. Currently there is no path expansion of the tilde with e.g. path.expand() call wrapping input/output paths, so you either need to set your WBT working directory to (full path of) your home directory and use relative paths (starting with "./") or use the full file paths.

EmFidan commented 2 years ago

It appears that was the issue. Coincidentally, that was the one thing I had not tested. Thank you for catching that!

brownag commented 2 years ago

I will look into an update that can make path expansion work with the various wbt_ functions. I think it is reasonable to expect R functions with file path arguments to do path expansion. Thanks for reporting the issue.