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
//! OxiGDAL Analytics - Advanced Geospatial Analytics
//!
//! This crate provides advanced analytics capabilities for geospatial data processing,
//! including time series analysis, spatial clustering, hotspot detection, change detection,
//! interpolation, and advanced zonal statistics.
//!
//! # Features
//!
//! ## Time Series Analysis
//!
//! Analyze temporal patterns in geospatial data:
//! - Trend detection (Mann-Kendall test, linear regression)
//! - Anomaly detection (Z-score, IQR, Modified Z-score)
//! - Seasonal decomposition
//! - Gap filling and smoothing
//!
//! ```
//! use oxigdal_analytics::timeseries::{TrendDetector, TrendMethod};
//! use scirs2_core::ndarray::array;
//!
//! let values = array![1.0, 2.0, 3.0, 4.0, 5.0];
//! let detector = TrendDetector::new(TrendMethod::MannKendall, 0.05);
//! let result = detector.detect(&values.view()).expect("Failed to detect trend");
//!
//! assert_eq!(result.direction, 1); // Positive trend
//! assert!(result.significant);
//! ```
//!
//! ## Spatial Clustering
//!
//! Identify clusters and outliers in spatial data:
//! - K-means clustering for image classification
//! - DBSCAN for spatial outlier detection
//! - Cluster validation metrics
//!
//! ```
//! use oxigdal_analytics::clustering::{KMeansClusterer, DbscanClusterer};
//! use scirs2_core::ndarray::array;
//!
//! let data = array![
//! [0.0, 0.0],
//! [0.1, 0.1],
//! [10.0, 10.0],
//! [10.1, 10.1],
//! ];
//!
//! // K-means clustering
//! let kmeans = KMeansClusterer::new(2, 100, 1e-4);
//! let result = kmeans.fit(&data.view()).expect("Failed to fit K-means clustering");
//! assert_eq!(result.centers.nrows(), 2);
//! ```
//!
//! ## Hotspot Analysis
//!
//! Detect spatial clusters of high or low values:
//! - Getis-Ord Gi* statistic (hot spot analysis)
//! - Moran's I (global and local spatial autocorrelation)
//! - LISA (Local Indicators of Spatial Association)
//!
//! ```
//! use oxigdal_analytics::hotspot::{GetisOrdGiStar, SpatialWeights};
//! use scirs2_core::ndarray::array;
//!
//! let values = array![1.0, 1.0, 10.0, 10.0];
//! let adj = array![
//! [1.0, 1.0, 0.0, 0.0],
//! [1.0, 1.0, 1.0, 0.0],
//! [0.0, 1.0, 1.0, 1.0],
//! [0.0, 0.0, 1.0, 1.0],
//! ];
//!
//! let weights = SpatialWeights::from_adjacency(adj).expect("Failed to create spatial weights from adjacency matrix");
//! let gi_star = GetisOrdGiStar::new(0.05);
//! let result = gi_star.calculate(&values.view(), &weights).expect("Failed to calculate Getis-Ord Gi* statistic");
//! ```
//!
//! ## Change Detection
//!
//! Detect changes between multi-temporal images:
//! - Image differencing
//! - Change Vector Analysis (CVA)
//! - Principal Component Analysis (PCA)
//! - Automatic threshold optimization (Otsu's method)
//!
//! ```
//! use oxigdal_analytics::change::{ChangeDetector, ChangeMethod};
//! use scirs2_core::ndarray::Array;
//!
//! let before = Array::from_shape_vec((2, 2, 1), vec![1.0, 2.0, 3.0, 4.0]).expect("Failed to create before array");
//! let after = Array::from_shape_vec((2, 2, 1), vec![2.0, 3.0, 4.0, 5.0]).expect("Failed to create after array");
//!
//! let detector = ChangeDetector::new(ChangeMethod::CVA);
//! let result = detector.detect(&before.view(), &after.view()).expect("Failed to detect changes");
//!
//! assert_eq!(result.magnitude.dim(), (2, 2));
//! ```
//!
//! ## Interpolation
//!
//! Create continuous surfaces from point data:
//! - Inverse Distance Weighting (IDW)
//! - Kriging (Ordinary and Universal)
//! - Variogram modeling
//! - Cross-validation
//!
//! ```
//! use oxigdal_analytics::interpolation::{IdwInterpolator, KrigingInterpolator, KrigingType, Variogram, VariogramModel};
//! use scirs2_core::ndarray::array;
//!
//! let points = array![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]];
//! let values = array![1.0, 2.0, 3.0];
//! let targets = array![[0.5, 0.5]];
//!
//! // IDW interpolation
//! let idw = IdwInterpolator::new(2.0);
//! let result = idw.interpolate(&points, &values.view(), &targets).expect("Failed to perform IDW interpolation");
//! ```
//!
//! ## Advanced Zonal Statistics
//!
//! Calculate statistics for regions:
//! - Multiple statistics (mean, median, min, max, std, etc.)
//! - Weighted statistics
//! - Multi-band support
//! - Custom aggregation functions
//!
//! ```
//! use oxigdal_analytics::zonal::{ZonalCalculator, ZonalStatistic};
//! use scirs2_core::ndarray::array;
//!
//! let values = array![[1.0, 2.0], [3.0, 4.0]];
//! let zones = array![[1, 1], [1, 1]];
//!
//! let calculator = ZonalCalculator::new();
//! let result = calculator.calculate(&values.view(), &zones.view()).expect("Failed to calculate zonal statistics");
//!
//! let zone1_stats = &result.zones[&1];
//! assert!(zone1_stats.contains_key(&ZonalStatistic::Mean));
//! ```
//!
//! # COOLJAPAN Policy Compliance
//!
//! This crate adheres to COOLJAPAN ecosystem policies:
//!
//! - **Pure Rust**: 100% Pure Rust implementation, no C/Fortran dependencies
//! - **No unwrap()**: All error cases are properly handled with `Result<T, E>`
//! - **SciRS2 Integration**: Uses `scirs2-core` for scientific computing instead of ndarray directly
//! - **Comprehensive Error Handling**: Custom error types for all failure modes
//! - **File Size Policy**: All source files are kept under 2000 lines
//! - **Latest Crates**: Uses latest versions from crates.io
//! - **Workspace Policy**: Follows workspace dependency management
//!
//! # Performance
//!
//! All algorithms are optimized for production use with:
//! - Efficient memory usage
//! - Vectorized operations where possible
//! - Optional parallel processing (enable `parallel` feature)
//! - Numerical stability checks
//!
//! # Safety
//!
//! This crate is designed with safety in mind:
//! - No unsafe code (except what's in dependencies)
//! - Comprehensive input validation
//! - Proper handling of edge cases (empty data, singular matrices, etc.)
//! - Clear error messages for debugging
// Pedantic disabled to reduce noise - default clippy::all is sufficient
// #![warn(clippy::pedantic)]
// Analytics functions can be complex
// Allow partial documentation during development
// Allow dead code for internal structures
// Allow needless range loop for explicit indexing
// Allow unused imports in analytics modules
// Re-export commonly used items
pub use ;
/// Crate version
pub const VERSION: &str = env!;
/// Crate name
pub const NAME: &str = env!;