MATERIALS AND METHODS

In the following sections, we describe the procedure for automated HMU classification and its application to selected stretches in three Norwegian rivers. First, we describe the structure of the automatedHMU classification system (Section 2.1), which uses a Norwegian mesohabitat assessment method based on surface flow pattern (identified by a CNN) and surface gradient. Secondly, we describe a system – aRefined surface pattern classification system – that incorporates an additional surface class (“diffusing foam ”) to better characterize flow features (Section 2.2). We then describe the application of these systems to remote sensing data of the selected river stretches (Section 2.3). All processing was done in R using theterra and insol libraries, with the exception of the CNN, which was run in python 3.9.7 using TensorFlow 2.9.1 (Joshi et al. 2018) with Keras 2.9.0.

Hydromorphological unit classification system

The HMU classification system was devised such that it could classify a river stretch into contiguous cells of preset dimensions (e.g. 10 × 10 m), where each cell is defined as one of four HMU classes (Figure 1), based on a decision tree using the surface pattern (a feature of the flow) and the surface gradient of the cell. This system is based on the mesohabitat classification system of Borsányi et al. (2004), which is commonly used within Norway, but is simplified in that the HMUs are broad in scope, and may include several of Borsányi’s mesohabitat types: for example, pools, walks and glides are within the same HMU. Surface patterns, classified into smooth or rippled surfaces (associated with more laminar flow) and standing waves , indicate broad conditions of the flow. HMU classes are defined as:
  1. Mild-smooth . This is characterized by a smooth or rippled surface pattern occurring in a mild surface gradient, and corresponds to the pool , glide and walk mesohabitat classes.
  2. Steep-smooth . This is characterized by a smooth or rippled surface pattern and a steep surface gradient, and corresponds to therun mesohabitat class.
  3. Mild-turbulent . This is characterized by a standing wave surface pattern and a mild surface gradient, and corresponds to thesplash and rill mesohabitat classes.
  4. Steep-turbulent . This is characterized by a standing wave surface pattern and a steep surface gradient, and corresponds to thecascade and rapid mesohabitat classes.
Following Borsányi (2006), standing waves are defined as undulations with a height ≥5 cm caused by interaction of the flow and the riverbed in the location of the standing wave and can either be broken (involving “white water”) or unbroken (lacking “white water”). Mild andsteep gradients are defined as those with a slope <4% and ≥4%, respectively. Surface patterns and gradients were defined across the river channel within cells of dimension 100 × 100 pixels (corresponding to 10 × 10 m for imagery with a pixel resolution of 0.1 × 0.1 m).
The two classes of surface patterns – (1) smooth or rippled ; and (2) standing waves – were classified using a CNN constructed using the TensorFlow and Keras libraries. The CNN consisted of two convolution layers (with zero padding), each followed by a pooling layer to down sample the feature maps (Figure 2). Convolution layers and the first dense layer had a rectified linear unit (relu) activation function. The training/validation dataset was split into separate training (70% of the data) and validation (30% of the data) sets using a random approach. The model was compiled using the Adam Optimizer Algorithm, using a sparse cross-entropy loss function with mini batch gradient descent (batch size = 32). Fifteen epochs (number of times the learning algorithm runs through the entire training dataset) were used to train the model: a greater number of epochs was not used as this sometimes led to overfitting models. The models were evaluated using training and validation accuracy and loss curves.

Refined surface pattern classification system

To test the ability to refine the surface pattern classification, the CNN was trained with three classes: (1) smooth or rippled ; (2)standing waves ; and (3) diffusing foam . Both the standing waves and the diffusing foam classes were characterized by unsmooth surfaces, typically with white water. However, standing waves were created locally; for example, waves overlying submerged boulders. The diffusing foam class represented areas where foam at the water surface had been created by upstream turbulence and was diffusing downstream by a process of advection (see Chanson 2012, Schilling & Zessner 2011). Model architecture was equivalent to that used in the two-class CNN.

Application of the classification systems

Remote sensing imagery

To classify surface patterns, aerial orthophotos (resolution = 0.1 × 0.1 m) were acquired from Norge i bilder (https://norgeibilder.no), an image repository of orthomosaics provided by the Norwegian Mapping Authority in collaboration with the Norwegian Public Roads Administration and the Norwegian Institute of Bioeconomics. To identify gradients, DTMs (resolution = 1 × 1 m) were obtained from the Høydedata portal (http://hoydedata.no) of the Norwegian Mapping Authority. DSM data, which showed surface elevation including surface objects such as trees and buildings, were also acquired from the Høydedata portal for use in image pre-processing (Section 2.3.2).
CNN training and validation. The CNNs used in the two classification systems – HMU classification system and theRefined surface pattern classification system – were trained using orthophotos of stretches of the rivers Nausta (central Norway) and Suldalslågen (south-west Norway) (Supplementary table 1). River stretches were compartmentalized into cells (100 × 100 pixels representing 10 × 10 m), and those cells showing clear examples of the surface pattern types – smooth or rippled (N = 279),standing waves (N = 166), and advective diffusion (N = 135) – were selected visually for use in training and validation (Figure 2).
CNN prediction. To predict surface patterns from the CNN and characterize HMUs, target images were acquired from stretches of the rivers Alta (stretch length ≈ 2700 m), Nidelva (stretch length ≈ 1000 m) and Orkla (stretch length = 2200 m) (Supplementary table 1). Images were selected on the basis of them containing a range of mesohabitats, as determined through bank-side observation and qualitative analysis of aerial photographs (see Borsányi 2006, Hindar et al. 2007). The imaged stretch of the river Alta was a mild-gradient meandering reach, ca. 80 m in width, with a sequence of areas with smooth or rippled surfaces over deeper waters (glides) and areas with standing waves over shallower waters (splashes). Two images of the river Nidelva were used, one acquired at low discharge and the other at high discharge, to examine how predicted HMUs changed according to discharge. The imaged stretch consisted of alternating fast turbulent flow mesohabitats (cascades, rapids, splashes) and mesohabitats with more laminar flows (pools, walks, glides) (see Borsányi 2006). The imaged stretch of the river Orkla mainly consisted of alternating glides and splashes, with the channel bifurcating around islands, but also included a short cascade in a steeper part of the channel. For all rivers, the manually mapped mesohabitat classes were used to derive manual HMU classifications.

Preprocessing of imagery

Surface pattern. Prior to selection of cells used in the CNN (for training and validation, and for prediction), areas outside of the channel and areas that were too dark to observe surface patterns (those under shadow) were removed by masking using the terra::mask R function.
Masking non-channel areas. Channel boundaries were digitized by modifying a polygon database of water bodies across Norway (included in the N50 Kartdata of the Norwegian Mapping Authority; https://www.kartverket.no/api-og-data/kartgrunnlag-fastlands-norge). Areas outside the polygons were then masked, leaving only the wetted channel.
Masking shaded areas. Shaded areas were identified by visual comparison of shadows in the orthophotos with predicted positions from a shading algorithm (insol::doshade R function). Raster maps of shadows were predicted from how the sun would cast shadows based on the elevations of ground surface features (estimated as the difference between the DSM and the DTM elevations) for solar azimuths and elevations on the day of imaging. The raster map of shadows that corresponded best to those in the orthophoto was then used to mask the orthophoto, leaving only the areas under direct sunlight.
Surface gradient. Non-channel areas of the DTM were masked by excluding pixels outside of the channel boundary polygon identified in the preprocessing of the aerial orthophotos. The gradient (expressed as a %) for each 1 × 1 m DTM pixel within the channel was estimated by a two-stage procedure: (1) a gradient (in degrees) was calculated using the 8 neighboring pixels with the terra:terrain R function, and converted to a percentage; (2) this gradient was subsequently smoothed using the terra:focal R function (bandwidth = 7 pixels, function = ”mean”). The result, referred to as the surface gradient , was used in the decision rule framework for automated classification of mesohabitats.