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
//! **terrand** — Pure-Rust terrain analysis on ndarray.
//!
//! Provides DEM (Digital Elevation Model) analysis without GDAL or any C
//! dependencies. All operations take `ndarray::Array2<f64>` as input and
//! return ndarray arrays as output, making them composable with the rest of
//! the Rust scientific computing ecosystem.
//!
//! # Modules
//!
//! | Module | Operations |
//! |--------|-----------|
//! | [`slope`](mod@slope) | Slope in degrees, radians, or percent |
//! | [`aspect`](mod@aspect) | Slope direction as compass bearing |
//! | [`curvature`](mod@curvature) | Profile, plan, and general curvature |
//! | [`hillshade`](mod@hillshade) | Shaded-relief illumination |
//! | [`roughness`](mod@roughness) | TRI, TPI, and surface roughness |
//! | [`hydrology`](mod@hydrology) | Fill, flow direction, accumulation, watershed, basin, stream order |
//! | [`viewshed`](mod@viewshed) | Line-of-sight visibility analysis |
//! | [`contour`](mod@contour) | Marching-squares contour generation |
//!
//! # Quick start
//!
//! ```
//! use ndarray::Array2;
//! use terrand::{slope, aspect, hillshade, CellSize};
//!
//! // A synthetic DEM with a uniform east-facing slope.
//! let dem = Array2::from_shape_fn((100, 100), |(_, c)| c as f64 * 10.0);
//! let cell = CellSize::square(30.0).unwrap();
//!
//! let s = slope(&dem, cell);
//! let a = aspect(&dem, cell);
//! let hs = hillshade(&dem, cell, 315.0, 45.0);
//! ```
//!
//! # Parallelism
//!
//! Enable the `parallel` feature to use Rayon for multi-threaded computation
//! on all per-cell operations:
//!
//! ```toml
//! [dependencies]
//! terrand = { package = "terrand-rs", version = "0.1", features = ["parallel"] }
//! ```
//!
//! # NaN and nodata handling
//!
//! NaN handling is operation-specific. Surface-analysis kernels generally
//! propagate `NaN` through their 3x3 arithmetic on normal-size grids, but their
//! small-grid fallbacks return documented flat values. Hydrology treats `NaN`
//! as nodata for elevation rasters: `fill` leaves `NaN` cells unchanged, while
//! `flow_direction` encodes `NaN` cells as direction `0`. Contour generation
//! treats `NaN` cells as holes and skips quads containing them.
//!
//! # Algorithms
//!
//! Slope, aspect, and hillshade use the Horn (1981) 3x3 weighted gradient
//! kernel with GDAL-compatible linear extrapolation at grid edges. Curvature
//! uses Horn first-order gradients with the same edge extrapolation, plus
//! finite-difference second derivatives clamped at grid edges.
// Internal modules (not part of public API).
// Public modules.
// Re-export primary types and functions at crate root for ergonomic access.
pub use ;
pub use CellSize;
pub use ;
pub use ;
pub use hillshade;
pub use ;
pub use ;
pub use ;
pub use ;