-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wbt_isobasins() crashed for any size >= 1e5, works well under #20
Comments
Hi Antoine, |
It throws the exact same error. |
What happens when you use the non-scientific notation format (i.e. 1e5 = 100000) as the size parameter. I imagine that the R frontend passes parameters to the WBT backend as strings. Rust likely does not like parsing integer values in the scientific notation, but I'll need to check into that. |
The error is likely caused by the scientific notation. Here are the R scripts behind the tool. https://github.com/giswqs/whiteboxR/blob/master/R/hydro_analysis.R#L1047
https://github.com/giswqs/whiteboxR/blob/master/R/wbt.R#L273:1
|
Thanks for your attention but it still does not resolve the problem. And it throwed the same error
It is really a threshold error as
|
I can confirm that this is related to scientific notation, even if the user specifies size as a value like Using the latest version of the package I can successfully run the following: wbt_run_tool("isobasins", "--dem=C:/Users/Andrew.G.Brown/Documents/R/win-library/4.0/whitebox/extdata/DEM.tif --output=foo.tif --size=1000000") In contrast this fails: > wbt_isobasins(dem = dem, output = "isobas_10km.tif", size = 100000, verbose_mode = TRUE)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src\tools\hydro_analysis\isobasins.rs:187:57
stack backtrace:
0: 0x7ff71c8fab5e - <unknown>
1: 0x7ff71c919bfc - <unknown>
2: 0x7ff71c8f6143 - <unknown>
3: 0x7ff71c8fdccb - <unknown>
4: 0x7ff71c8fd918 - <unknown>
5: 0x7ff71c8fe49f - <unknown>
6: 0x7ff71c8fe01f - <unknown>
7: 0x7ff71c917270 - <unknown>
8: 0x7ff71c9170a3 - <unknown>
9: 0x7ff71c5e01af - <unknown>
10: 0x7ff71beeaf24 - <unknown>
11: 0x7ff71c79b3f9 - <unknown>
12: 0x7ff71c798871 - <unknown>
13: 0x7ff71c6b6b86 - <unknown>
14: 0x7ff71c8fe796 - <unknown>
15: 0x7ff71c79d337 - <unknown>
16: 0x7ff71c92be55 - <unknown>
17: 0x7ffec7ba7c24 - BaseThreadInitThunk
18: 0x7ffec95ad721 - RtlUserThreadStart
Warning message:
In system(args2, intern = TRUE) :
running command '"whitebox_tools.exe" --run=isobasins --dem=C:/Users/Andrew.G.Brown/Documents/R/win-library/4.0/whitebox/extdata/DEM.tif --output=isobas_10km.tif --size=1e+05 -v' had status 101 I think we could probably handle > paste0("a=", as.integer(1e5))
[1] "a=100000"
> paste0("a=", 1e5)
[1] "a=1e+05" Otherwise, folks can use a non-default
|
Also, explicitly setting a numeric literal as an integer using
> wbt_isobasins(dem = "DEM.tif", output = "isobas_10km.tif", size = 100000L)
isobasins - Elapsed Time (excluding I/O): 0.6s |
I am going to close this issue via a PR hat implements some of the required steps to implement this. The process that generates functions from the latest WhiteboxTools python script needs additional information parsed from the JSON specification of tool parameters. This is a step beyond the current heuristics which rely on the contents of the whitebox_tools.py file. The process to update internal |
You can look at the get_wbt_dict() function. I use it to extract tool parameters as a json file. You can probably directly use this json file to build R functions |
Yes, I used to build a custom .json file by running Currently that gets run like so for building the package datasets in data-raw folder: Probably can move the reticulate based code to make the JSON file into PY2R/automate.py and then have the data-raw steps called on the updated json file (in data-raw folder) at end of that script, so only one script needs to be run |
Hello,
First of all thank you for this whitebox and its interface in R. I think it's a good tool for reproductible research in GIS, and it certainly makes some fastidious work with rgdal and raster easier.
I found what I think is a bug and I have no competence to fix it as I don't understand Rust.
When I try the to use the iso_basins() it works well for any size < 1e5 and crashes for any size > 1e5 (see exemple and console output below)
This bug was reproducted with two different Windows computer (10 standard and 10 Pro), an up-to-date whitebox install and two different R Version (3.61 and 4.0.0).
If you can have a look I would be grateful.
The text was updated successfully, but these errors were encountered: