diff --git a/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs b/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs index c70f6f90..5a28a8c3 100755 --- a/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs +++ b/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs @@ -360,15 +360,16 @@ impl WhiteboxTool for DownslopeFlowpathLength { // find its downslope neighbour dir = pntr.get_value(y, x); if dir > 0f64 && dir != nodata { - if dir > 128f64 || pntr_matches[dir as usize] == 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.")); - } // move x and y accordingly c = pntr_matches[dir as usize]; x += dx[c]; y += dy[c]; + if dir > 128f64 || c == 999 || pntr.get_value(y, x) == nodata { + 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.")); + } + dist += grid_lengths[c] * weights.get_value(y, x) as f64; if output.get_value(y, x) != -999f64 {