# 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  
A positive terrain-constrained ridgeline extraction method is proposed to overcome the problem that it is difficult to determine the threshold of flow accumulation when extracting ridgelines using the traditional runoff simulation method. Combining morphological characteristics with runoff simulation, the simulated ridgelines are extracted using positive terrain membership degree and morphological analysis, and the optimal threshold of the flow accumulation is determined by the simulated ridgelines' length. Then, the ridgelines are extracted using the runoff simulation method with the optimal flow accumulation threshold. The workflow of this method is shown in Figure 3.  
Figure 3: Processes of the positive terrain-constrained ridgeline extraction. **Optimal window size determination of the positive terrain analysis**. Ridgelines are the prominent structural line of positive terrain. Positive and negative terrain are relatively high or low parts of a certain area, respectively [39]. Based on the summary of previous studies, [PERSON] et al. concluded that the positive terrain of the loess ridges and hills area could be distinguished according to the valley lines, while other topography needs to be analyzed according to local terrain [40]. According to the above views, the positive terrain based on the DEM data can be defined as the relatively convex part under local window analysis, while the negative terrain can be defined as the relatively concave part. This can be distinguished by the macroscopic slope factor [41]:  
\[P=H_{i,j}-(\sum\limits_{k=1}^{n}H_{k})/n \tag{1}\]  
where \(H_{i,j}\) is the elevation value of the window's center pixel, \(\sum\limits_{k=1}^{n}H_{k}\) is the sum of the elevation values in the window and \(n\) is the number of pixels in the window. When \(P>0\), the center pixel of the window is a positive terrain pixel. The multi-scale characteristic is ubiquitous in almost all geography-related fields [42; 43]. Therefore, combined with Equation (1), it can be seen that the analysis window size plays a vital role in whether it is positive terrain. At present, the determination of the optimal analysis window size is mainly to seek the analysis window size. The local mean variance (LMV) method is simple to calculate and the results are easy to analyze, so it is widely used in scale analysis [44; 45]. For regions with complex topography, such as karst areas, [PERSON] et al. proposed the local normalized variance [46]:  
\[LNV=\frac{LMV}{r^{2}} \tag{2}\]  
where \(LMV\) is the mean variance of the elevations in the analysis window, and \(r\) is the number of grid cells corresponding to the analysis window's radius. The variance values are normalized to a uniform unit on one grid cell by dividing by the analysis window's radius, which improves the comparability of the method across different regions. Since the topography of the Loess Plateau is more complex compared with that of the karst region, normalization using \(r^{2}\) is not conducive to the presentation and analysis of topographic details. Therefore, based on the characteristics of the Loess Plateau, this paper derives the Loess local normalized variance:  
\[LLNV=\frac{LMV}{2r} \tag{3}\]  
Based on Equation (3), calculating the \(LLNV\) sequences:  
\[\textbf{S}=\{LLNV_{k\times k}|\ k=3,s,\ldots,k-s,k\} \tag{4}\]  
until it is found that:  
\[LLNV_{k,k}-LLNV_{k-s,k-s}\leq 0 \tag{5}\]  
This means looking for the local maximum point \(LLNV_{k,k}\) of the \(LLNV\) sequence \(S\), and its corresponding analysis window size \(k\) is the optimal analysis window size for positive terrain, where \(s\) is the step for finding the optimal analysis window size. **Optimal threshold determination of the flow accumulation**. In hydrological analysis, the threshold of the flow accumulation significantly impacts the results. An optimal threshold of flow accumulation can greatly improve the quality of ridgelines obtained from the hydrological analysis.