This tool can be used to identify the main channel in a stream network. The user must input a D8 pointer (flow direction) raster (d8_pointer), and a streams raster (`streams_raster`). The pointer raster is used to traverse the stream network and should only be created using the d8_pointer tool. By default, the pointer raster is assumed to use the clockwise indexing method used by WhiteboxTools:

| . | . | .
64 | 128 | 1
32 | 0 | 2
16 | 8 | 4

If the pointer file contains ESRI flow direction values instead, you must set `esri_pointer=True` parameter must be specified.

The streams raster should have been created using one of the DEM-based stream mapping methods, i.e. contributing area thresholding. Stream grid cells are designated in the streams image as all positive, non-zero values. All non-stream cells will be assigned the NoData value in the output image, unless the user sets `zero_background=True`.

The algorithm operates by traversing each stream and identifying the longest stream-path draining to each outlet. When a confluence is encountered, the traverse follows the branch with the larger distance-to-head.

## See Also

d8_pointer

## Function Signature

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

## Project Links

WbW Homepage User Manual Support WbW