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
//! Geostatistical kriging library with ordinary and binomial kriging, variogram fitting,
//! and optional WASM and GPU support.
//!
//! This crate provides spatial interpolation via ordinary kriging and prevalence-surface
//! estimation via binomial kriging. **Default binomial kriging** is empirical-Bayes
//! (Beta-prior) logit on the link, **calibrated** ordinary kriging with per-site logit
//! observation variance on the covariance diagonal, and logistic back to prevalence; see
//! [`BinomialKrigingModel`] and [`BinomialBuildNotes`] (not a full binomial-likelihood
//! spatial model). The crate also includes empirical variogram computation, parametric model
//! fitting, and Haversine-based geographic coordinates. Build with `wasm` for browser
//! bindings or `gpu` for GPU-accelerated batch prediction.
//!
//! # Scope
//!
//! - **Geographic by default.** Coordinates are `(latitude, longitude)` in degrees and the
//! default distance is Haversine (great-circle, kilometers). This works globally, including
//! near the poles and across the antimeridian, to the precision allowed by the selected
//! floating-point type (see the `f64` feature below for double precision).
//! - **2-D spatial fields and 2+1-D spatio-temporal fields.** The root `kriging` module
//! covers surfaces that are functions of two spatial coordinates; the [`spacetime`] module
//! adds an additional scalar time axis with the same four kriging families (ordinary,
//! simple, universal, binomial). There is no 3-D (volumetric) kriging in this crate.
//! - **Planar data is supported via [`projected`].** `ProjectedCoord` + Euclidean distance +
//! [`Anisotropy2D`] let you krige `(x, y)` data in any linear unit (meters, grid cells,
//! pixels). Convert between lat/lon and planar with [`ProjectedCoord::equirectangular`]
//! for small areas where the sphere-vs-plane distortion is negligible. The spatio-temporal
//! models are generic over the spatial geometry and accept both geographic and projected
//! coordinates via the [`spacetime::SpatialMetric`] trait.
//!
//! # WASM initialization
//!
//! When using the `kriging-rs-wasm` npm wrapper, you must call and `await` `init()` once
//! before constructing any model. The wrapper guards against the JS-glue-before-WASM race
//! (it only marks the module ready after the underlying instantiation resolves) — but if
//! you build your own bindings, make sure the WebAssembly instance is fully available
//! before calling constructors, otherwise you will see cryptic `TypeError`s from
//! `wasm_bindgen`.
//!
//! # Quick example
//!
//! ```rust
//! use kriging_rs::{GeoCoord, GeoDataset, OrdinaryKrigingModel, VariogramModel, VariogramType};
//!
//! # fn main() -> Result<(), kriging_rs::KrigingError> {
//! let coords = vec![
//! GeoCoord::try_new(0.0, 0.0)?,
//! GeoCoord::try_new(0.0, 1.0)?,
//! GeoCoord::try_new(1.0, 0.0)?,
//! ];
//! let values = vec![1.0, 2.0, 1.5];
//! let dataset = GeoDataset::new(coords, values)?;
//! let variogram = VariogramModel::new(0.01, 2.0, 300.0, VariogramType::Exponential)?;
//! let model = OrdinaryKrigingModel::new(dataset, variogram)?;
//! let prediction = model.predict(GeoCoord::try_new(0.3, 0.3)?)?;
//! # let _ = prediction.value;
//! # Ok(())
//! # }
//! ```
//!
//! # Module organization
//!
//! - [`kriging`] — Ordinary kriging ([`OrdinaryKrigingModel`], [`Prediction`]) and binomial
//! kriging ([`BinomialKrigingModel`], [`BinomialObservation`], etc.) for spatial interpolation
//! and prevalence surfaces.
//! - [`variogram`] — Empirical variogram ([`compute_empirical_variogram`]), fitting
//! ([`fit_variogram`]), and parametric models ([`VariogramModel`], [`VariogramType`]).
//! - [`spacetime`] — Spatio-temporal kriging (ordinary, simple, universal, binomial) with
//! separable and product-sum space-time variograms, empirical + parametric fitting, and
//! generic spatial metrics (geographic or projected).
//! - [`distance`] — [`GeoCoord`] and Haversine distance.
//! - [`geo_dataset`] — Coordinate–value datasets ([`GeoDataset`]).
//! - [`error`] — [`KrigingError`].
//! - `wasm` (optional, `wasm` feature) — Browser-facing WASM bindings.
//! - `gpu` (optional, `gpu` feature) — GPU backend and batch covariance helpers.
//!
//! # Features
//!
//! Default build has no WASM or GPU. Enable with:
//!
//! - `wasm` — WASM bindings and browser support.
//! - `gpu` — WebGPU-based batch prediction (native and web).
//! - `gpu-blocking` — Blocking GPU helpers on native (includes `gpu`).
/// Floating-point type used for coordinates, values, and variogram parameters.
///
/// Defaults to `f32`. Enable the `f64` Cargo feature to switch to double precision at the
/// cost of ~2x memory and slightly slower math; useful for dense station layouts where the
/// `f32` kriging matrix is close to numerically singular. Incompatible with the `gpu`
/// feature because WGSL shaders hard-code `f32`.
pub type Real = f32;
pub type Real = f64;
compile_error!;
/// Dense linear-system helpers used internally by kriging models. Not part of the stable
/// public API — use the higher-level `*KrigingModel` types to predict values; direct solver
/// access is a crate-internal detail that may be removed in a future release.
pub
pub use ;
pub use GeoCoord;
pub use KrigingError;
pub use GeoDataset;
pub use ;
pub use ;
pub use ;
pub use SimpleKrigingModel;
pub use ;
pub use ;
pub use ;
pub use ;
pub use NestedVariogram;
pub use ;