opengeos / whiteboxR

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

How to list input rasters #115

Closed plinthite closed 1 year ago

plinthite commented 1 year ago

I would like to use wbt_k_means_clustering(), but cannot figure out the syntax for the "inputs" rasters. I've tried using c(r1, r2, r3), a 3 band tif, paste0(r1name, ";", r2name, ";", r3name), as might work for python syntax, and other combinations. Could you please supply an example of how to list multiple input rasters for this function in R?

brownag commented 1 year ago

paste0(r1name, ";", r2name, ";", r3name) (or the equivalent using comma separators) should work. Be sure that r1name refers to a full path to a file that exists and contains only one band.

For example, the following command works for me on Windows. The multifile inputs (specified with semicolon) are quoted and comma-separated internally:

"whitebox_tools.exe" --run=KMeansClustering  --inputs="DEM.tif,DEM.tif" --output="D:/test.tif" --classes=3 --out_html=test --max_iterations=10 --class_change=2 --initialize=diagonal --min_class_size=10 -v

the wbt_*_*() functions do not support RasterLayer/SpatRaster objects directly, only file paths, and most (but not all) Whitebox tools do not support multiband GeoTIFF.

plinthite commented 1 year ago

Thank you!! This was complicated by running in via rstudio in a container, and apparently I had to specify paths for the output files as well.