# An Integrated Algorithm for Extracting Terrain Feature-Point Clusters Based on DEM Data
## 2 Materials and Methods
### Methods
#### 2.2.1 Positive Terrain-Constrained Ridgeline Extraction
The ridgelines can be regarded as the skeleton lines of the positive terrain. Thus, the skeleton lines of positive terrain are obtained by thinning the positive terrain's profile. Next, the ridgelines' lengths extracted by the hydrological analysis are constrained by the skeleton lines' lengths of the positive terrain, and thus, the optimal threshold of the flow accumulation in the hydrologic analysis is obtained by theseconstraints. Meanwhile, considering the boundary fuzziness and hierarchical separability of the terrain, it can be considered that there is a fuzziness about whether the center pixel in the window on the DEM data is positive terrain. Thus, positive terrain should be continuous in a sequence of multi-neighborhood analysis windows [47; 48]. On the other hand, the hierarchical separability of terrain indicates that the multi-neighborhood analysis window must have the designated boundary of terrain hierarchy, and the terrain analysis from one terrain hierarchy to another has no transverse comparability [49]. Therefore, instead of directly using the positive terrain obtained with the optimal window size to extract the skeleton lines of the positive terrain, this paper introduces multiple neighborhoods to transform the positive terrain's profile extraction into a fuzzy logic discrimination problem. On this basis, the membership degree of positive terrain is defined as:  
\[\lambda=\sum_{k=min}^{max}H(i,j)_{k}/(max-min+1) \tag{6}\]  
where \(H(i,j)_{k}\) is the positive terrain state value corresponding to the pixel \((i,j)\), if the pixel is in positive terrain when the window size is \(k\), the state value is assigned to 1, otherwise it is 0; \(min\) and \(max\) are the minima and maxima side lengths of the analysis window, respectively. The \(min\) is usually set to 3, and the \(max\) is set to the optimal analysis window size obtained by the LLNV mentioned in Step 1. In Equation (6), the positive terrain obtained from neighborhood analysis with different windows sizes is considered to be of equal importance, and its weighting function is defined as equal weight. After obtaining the membership degree of positive terrain, the corresponding positive terrain outlines are acquired according to the corresponding membership degree requirements. Then, the skeleton lines of the positive terrain are obtained using a morphological thinning operation [50], and their lengths \(L\) are calculated. On the other hand, the watershed boundary lines under different flow accumulation thresholds are extracted using the runoff simulation method [29]. Next, the boundary lines obtained by each flow accumulation threshold \(T\) are filtered by positive terrain to obtain the potential ridgelines and calculate their lengths \(f(T)\), respectively. The flow accumulation threshold \(T\) for obtaining potential ridgelines can be constrained by the skeleton lines' lengths \(L\) of the positive terrain extracted by morphological analysis. Finally, the best flow accumulation threshold \(T^{\prime}\) can be obtained by making \(L=f(T)\). **Ridgeline extraction based on the runoff simulation method**. On natural surfaces, water always flows from high to low along the steepest direction and continuously converges downstream. The runoff simulation method determines the flow directions based on this view. The water volume is redistributed by the flow directions, and each cell's final accumulated water volume in the DEM data after the end of the flow is calculated. Then, the cells whose sink volume is greater than the manual threshold are taken as sink points (valley points). Finally, these candidate points are connected according to specific rules, and the results are considered as the sink lines (valley line) [26; 51]. The upstream supply areas can be obtained by searching upstream along the sink lines, and the watershed boundaries can be obtained by sketching the water supply areas. In this paper, the watershed boundaries are extracted using this method with the above best flow accumulation threshold \(T^{\prime}\).