Skip to content
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

Watershed tool fails when pour-points are provided as shape file #441

Open
tjgrabs opened this issue Jan 23, 2025 · 0 comments
Open

Watershed tool fails when pour-points are provided as shape file #441

tjgrabs opened this issue Jan 23, 2025 · 0 comments

Comments

@tjgrabs
Copy link

tjgrabs commented Jan 23, 2025

When trying to delineate a watershed using a flow pointer raster and a shape file with one pour point, the watershed tool crashes. The same operation works, if the pour point is provided as a raster file.

Note, that this issue seems to be different from the one reported here: Watershed Tool - thread 'main' panicked at 'Unrecognized raster type' #153

System: Windows 10 (all updates until 2025), Whitebox tools version 2.4.0, whitebox_runner.exe, and command line window.

Steps to reproduce:

  1. Unpack the attached zip file
  2. Start whitebox runner
  3. Provide links to (a) the D8 pointer file, (b) the Input pour points (use shape file), and check that the flow pointer uses the esri-schme
  4. Run the tool

Attached fle: 20250123_WBT_Watershed_Issue.zip

The problem can also be reproduced even using command line or QGIS (with the latest whitebox plugin).

I also ran the following command using cmd after enabling rust backtracing:

C:\misc\whitebox_tools.exe -r=Watershed --wd="D:\misc\wtr_shd.tif" --d8_pntr='D:\misc\pntr_D8_esri.tif' --pour_pts='D:\misc\pourpoint.shp' --output='D:\misc\wtr_shd.tif' --esri_pntr -v=true --compress_rasters=true

This produced the following error message and backtrace:
Reading data...
Locating pour points: 0%
thread 'main' panicked at whitebox-tools-app\src\tools\hydro_analysis\watershed.rs:321:60:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
0: 0x7ff74a174f3a -
1: 0x7ff74a19719b -
2: 0x7ff74a170b41 -
3: 0x7ff74a174d26 -
4: 0x7ff74a17714f -
5: 0x7ff74a176de7 -
6: 0x7ff74a17768d -
7: 0x7ff74a177549 -
8: 0x7ff74a175849 -
9: 0x7ff74a177206 -
10: 0x7ff74a1b9a97 -
11: 0x7ff74a1b9c44 -
12: 0x7ff7498ea27c -
13: 0x7ff7495637e6 -
14: 0x7ff74955e957 -
15: 0x7ff748ecca96 -
16: 0x7ff749e6d05c -
17: 0x7ff74a16b792 -
18: 0x7ff74956afcc -
19: 0x7ff74a1a970c -
20: 0x7ffb263a7ac4 - BaseThreadInitThunk
21: 0x7ffb27f6a8c1 - RtlUserThreadStart

If I interpret the backtrace correctly, the issue seems to occur in line 321:

Image

I tried to dig deeper to understand how Whitebox handles shapefiles, but, as I am not (yet) familiar with Whitebox' source code and Rust, I didn't go further. If I were to guess, I would suspect either an issue with the shape file (created in QGIS) and/or an issue with how Whitebox handles the shape file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant