Distance to Outlet Returning 0 for entire stream network #359
-
Hi, I'm trying out the distance_to_outlet function but am finding it returns "nodata" for all stream cells. Any guidance would be much appreciated. Example dem, d8 flow direction, and stream network rasters attached.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I'll answer my own question here in case someone else runs into this issue. The Distance to Outlet algorithm first looks for the outlet, then traverses upstream to calculate distances. The script looks for outlet cells around line 308 in if dir > 0 {
if dir > 128 || pntr_matches[dir] == 999 {
return Err(Error::new(ErrorKind::InvalidInput,
"An unexpected value has been identified in the pointer image. This tool requires a pointer grid that has been created using either the D8 or Rho8 tools."));
}
} else {
// It's an outlet; add it to the stack
stack.push((row, col));
output[(row, col)] = 0f64;
} The flow direction raster I used is clipped from a larger one which means the outlet isn't simply a stream cell with direction 0. One solution is to not pre-process the flow direction, and instead to clip the DEM and then condition and process flow direction, accumulation, streams, etc. Unfortunately this explodes my data processing pipeline. Since stream cells by definition are linked by flow direction, another way might be to find the end of the chain, i.e. stream cells that point to no other stream cell. |
Beta Was this translation helpful? Give feedback.
-
Although about a year ago I managed to figure out how to set up a development environment to test changes to rust code, I'm embarrassed to admit I couldn't follow the documentation to do so to look into this problem and test a potential alternative. I tried installing the binary and getting live reloading with cargo watch. It seemed to detect when I made changes to rust scripts, but running a (Python) script wasn't seeing the updated version. I created a fresh environment with Any suggestions on setting up a development environment with a live update for rust would be much appreciated! |
Beta Was this translation helpful? Give feedback.
I'll answer my own question here in case someone else runs into this issue. The Distance to Outlet algorithm first looks for the outlet, then traverses upstream to calculate distances.
The script looks for outlet cells around line 308 in
dist_to_outlet.rs
by finding stream cells whose corresponding flow direction is 0 (directionless).