This tool calculates, for each stream grid cell in an input streams raster (`streams_raster`) the total length of channels upstream. The user must specify the name of a raster containing streams data (`streams_raster`), where stream grid cells are denoted by all positive non-zero values, and a D8 flow pointer (i.e. flow direction) raster (d8_pointer). The pointer image is used to traverse the stream network and must only be created using the D8 algorithm. Stream cells are designated in the streams image as all values greater than zero. Thus, all non-stream or background grid cells are commonly assigned either zeros or NoData values. Background cells will be assigned the NoData value in the output image, unless the user specifies `zero_background=True`, in which case non-stream cells will be assigned zero values in the output.

By default, the pointer raster is assumed to use the clockwise indexing method used by WhiteboxTools. If the pointer file contains ESRI flow direction values instead, set `esri_pntr=True`.

## See Also

farthest_channel_head, find_main_stem

## Function Signature

`def length_of_upstream_channels(self, d8_pointer: Raster, streams_raster: Raster, esri_pointer: bool = False, zero_background: bool = False) -> Raster: ...`

## Project Links

WbW Homepage User Manual Support WbW