-
Notifications
You must be signed in to change notification settings - Fork 196
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
How to exclude NoData values when calculating the flow direction of DEM? #256
Comments
If I don't set the NoData value, it will report the same error. |
I have found the same issue and also when loading some rasters. I think some of this is related to a new update in the Numpy package from 1.2x -> 2.0.0 (released in june). I only have these issues with the new version of Numpy and not when I downgrade it to 1.2x. Your screenshow shows that you get a typeerror in sview.py which is a result of this function call np.can_cast(viewfinder.nodata, obj.dtype, casting='safe') in line 85 See also the discussion here on fx the function can_cast, which is used for checks in the pysheds package: numpy/numpy#24856 |
@phillipaarestrup But my NumPy version is 1.24.3, and I am still encountering this issue. |
I tried NumPy 2.0 and the nodata representation error pops up when running flodir. However, with NumPy 1.26, it is working pretty good, |
@mht2953658596 try converting your raster to float before using the code. |
Changes the TypeError message while casting from viewfinder.nodata to obj data type. This help with issue mdbartos#256 How to exclude NoData values when calculating the flow direction of DEM.
Here's a workaround: you can pass the parameter
The same issue affects the accumulation function, and the workaround is the same: |
@col16 thank you for providing a workaround. I used it for both the flow direction and accumulation functions and was finally able to avoid the 'nodata' TypeError. Continuing with the workflow, I still received the error message when trying to run the snap_to_mask function. Is there a workaround for this function or for the catchment function (unsure yet if that will raise the same issue). I tried the same as above but was unsuccessful. Thank you in advance. |
Update: I found that downgrading to Numpy 1.26 allowed me to complete the delineation without using any provided workarounds. |
When using PyShed to calculate the flow direction of DEM, I found that the flow direction was also calculated for areas where DEM values were NoData. How can I avoid this situation?
When I set NoData using the following code:
it reports the following error:
The text was updated successfully, but these errors were encountered: