Skip to content

Preparing the DEM

One of the most powerful features of TINerator is the ability to create meshes which are variably refined around some DEM feature, such as a river or stream network.

To prepare the DEM for mesh generation, a feature needs to be (optionally) defined, and a boundary generated. Note that an option in TINerator exists to generate a mesh without feature refinement - see the mesh generation section for more information.

Watershed Delineation

Defining a river or stream network ('feature') in the DEM is done through the command:

my_dem.watershed_delineation(4500.)

Performing a watershed delineation is a multi-step process:

  1. Depressions ('pits') are filled
  2. Flats are resolved
  3. Flow accumulation is performed

Resolving Depressions and Flats

Lindsay (2016) Depression Topology

Source: Lindsay, John. (2015). Efficient hybrid breaching-filling sink removal methods for flow path enforcement in digital elevation models. Hydrological Processes. 30. 846–857. doi: 10.1002/hyp.10648.

Flow accumulation algorithms are numerous, but they all tend to operate relative to elevation deltas between adjacent DEM cells.

Consequently, flats and pits can disrupt accumulation algorithms, causing premature termination of the flow patterns. It is therefore, in general, best to preprocess a DEM to remove depressions and flats.

DEM Pits and Flats Depressions and flats identified and removed on a standard DEM

Flat and pit resolution is the default behavior of the watershedDelineation function. For more information on better controlling these steps, refer to the API Documentation.

The DEM feature will be found in the class variable tinerator.DEM.feature, and is an N-by-2 np.ndarray defining a polyline.

Flow accumulation

A critical step in determining river networks is through flow accumulation algorithms. These algorithms generate a raster of accumulated flow by accumulating the weight of all cells that flow into adjacent cells with a negative elevation data ('downslope cells').

Flow accumulation

Source: ArcGis Pro, How Flow Accumulation works

TINerator supports a number of popular flow accumulation algorithms:

  • D8
  • D4
  • D-Infinity
  • Rho8
  • Rho4
  • Quinn
  • Freeman
  • Holmgren

By default, D8 is used. For more information on these different algorithms, visit the RichDEM Flow Metrics page.

After flow accumulation is performed, the feature can be extracted by setting an accumulation threshold and defining all cells above that threshold to be a part of the feature.

As an example, see the below figure:

Watershed delineation

Left: Flow accumulation intensity. Right: Feature pulled by thresholding the flow accumulation matrix.

On the left, the raster generated by the flow accumulation algorithm is displayed. Note that effectively all non-masked cells in the DEM have some non-zero amount of accumulation. By settings threshold = 0., effectively the entire DEM would be 'captured' as a feature. Note that, if you only consider cells with more than 10^4 accumulations, a river network becomes visible.

Consequently, the threshold should be set to reflect that. Here, threshold = 4.5E10, and the feature derived from setting that threshold value is shown on the right of the figure.

Note

The optimal threshold value will change for each distinct DEM. Pay careful attention to set a value relative to your workflow goals.

Boundary Generation

Boundary generation is done using a Square Tracing Algorithm to quickly capture the perimeter of the DEM. The boundary is defined as the interface between cells with NoDataValue entries (z_{i,j} = NDV) and cells with data (z_{i,j} \ne NDV).

For DEMs that do not have cells with NoDataValue elements (z(i,j) \cap NDV = \emptyset), a rectangular boundary spanning the domain of the DEM is generated instead.

The boundary is generated automatically on DEM.build_refined_triplane or DEM.build_uniform_triplane.

DEM boundary generation

This boundary can be previewed using

tin.plot.preview_boundary(my_dem)