1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//! Advanced terrain analysis algorithms
//!
//! This module provides comprehensive terrain analysis metrics beyond basic
//! slope and aspect calculations. These metrics are essential for geomorphology,
//! hydrology, and landscape ecology studies.
//!
//! # Terrain Metrics
//!
//! ## Topographic Position Index (TPI)
//!
//! TPI compares the elevation of a point to the mean elevation of its neighborhood.
//! Positive values indicate ridges/peaks, negative values indicate valleys, and
//! values near zero indicate flat areas or mid-slope positions.
//! Supports both rectangular and annular (ring) neighborhoods.
//!
//! ## Terrain Ruggedness Index (TRI)
//!
//! TRI quantifies topographic heterogeneity by calculating the difference between
//! a center cell and its neighbors. Supports both Riley et al. (1999) method
//! (square root of sum of squared differences) and the simple mean absolute
//! difference method.
//!
//! ## Surface Roughness
//!
//! Roughness measures the variability in elevation within a neighborhood, using
//! either standard deviation or range (max - min) methods.
//!
//! ## Curvature
//!
//! Curvature describes the shape of the terrain surface:
//! - **Profile curvature**: Rate of change of slope (affects flow acceleration)
//! - **Planform curvature**: Curvature perpendicular to slope (affects flow convergence)
//! - **Total curvature**: Combined measure of surface curvature (Laplacian)
//! - **Mean curvature**: Average of principal curvatures
//! - **Gaussian curvature**: Product of principal curvatures
//! - **Tangential curvature**: Curvature in direction perpendicular to slope
//! - **Convergence index**: Measure of flow convergence/divergence
//!
//! ## Vector Ruggedness Measure (VRM)
//!
//! VRM calculates terrain ruggedness as the dispersion of normal vectors
//! to the surface, providing a scale-independent measure of roughness.
//!
//! ## Terrain Classification
//!
//! Landform classification using TPI at multiple scales following Weiss (2001)
//! and Jenness (2006) methodologies, classifying terrain into categories such
//! as valley bottoms, ridges, plains, upper/lower slopes, etc.
//!
//! ## Topographic Wetness Index (TWI)
//!
//! TWI = ln(a / tan(beta)) where a is specific catchment area and beta is slope.
//! Used in hydrological modeling to predict soil moisture distribution.
//!
//! ## Stream Power Index (SPI)
//!
//! SPI = a * tan(beta) where a is specific catchment area and beta is slope.
//! Measures erosive power of flowing water.
//!
//! # References
//!
//! - Burrough, P.A. & McDonnell, R.A. (1998). Principles of GIS.
//! - Riley, S.J. et al. (1999). A terrain ruggedness index.
//! - Weiss, A. (2001). Topographic Position and Landforms Analysis.
//! - Jenness, J. (2006). Topographic Position Index extension for ArcView.
//! - Zevenbergen, L.W. & Thorne, C.R. (1987). Quantitative analysis of land surface topography.
//! - Sappington, J.M. et al. (2007). Quantifying landscape ruggedness (VRM).
use crate;
use RasterBuffer;
use RasterDataType;
use *;
// ---------------------------------------------------------------------------
// TRI method variants
// ---------------------------------------------------------------------------
/// Method for computing Terrain Ruggedness Index
// ---------------------------------------------------------------------------
// Roughness method variants
// ---------------------------------------------------------------------------
/// Method for computing surface roughness
// ---------------------------------------------------------------------------
// Curvature types
// ---------------------------------------------------------------------------
/// Curvature types
// ---------------------------------------------------------------------------
// Landform classification
// ---------------------------------------------------------------------------
/// Landform classes following Weiss (2001) TPI-based classification
// ---------------------------------------------------------------------------
// TPI Neighborhood configuration
// ---------------------------------------------------------------------------
/// Neighborhood shape for TPI computation
// ===========================================================================
// TPI
// ===========================================================================
/// Computes Topographic Position Index (TPI) with configurable neighborhood
///
/// TPI = elevation - mean(neighborhood elevation)
///
/// Supports rectangular and annular (ring) neighborhoods.
/// Annular neighborhoods are particularly useful for multi-scale analysis
/// (Weiss, 2001; Jenness, 2006).
///
/// # Arguments
///
/// * `dem` - Digital elevation model
/// * `neighborhood_size` - Size of neighborhood (must be odd)
/// * `cell_size` - Size of each cell (for scaling)
///
/// # Errors
///
/// Returns an error if the operation fails
// Submodules
// Re-exports
pub use compute_curvature;
pub use ;
pub use ;
pub use ;