pyinterp.RTree.kriging¶
- RTree.kriging(coordinates: ndarray, *, radius: float | None = None, k: int = 9, covariance: str | None = None, drift_function: str | None = None, sigma: float = 1.0, alpha: float = 1000000.0, nugget: float = 0.0, within: bool = True, num_threads: int = 0) tuple[ndarray, ndarray][source]¶
Interpolate the values of a point using kriging.
- Parameters:
coordinates – a matrix of shape
(n, 3), wherenis the number of observations and 3 represents the coordinates in theorder: x, y, and z. If the matrix shape is(n, 2), the z-coordinate is assumed to be zero. The coordinates (x, y, z) are in the Cartesian coordinate system (ECEF) if the instance is configured to use this system (ecef keyword set to True during construction). Otherwise, the coordinates are in the geodetic system (longitude, latitude, and altitude) in degrees, degrees, and meters, respectively.radius – The maximum radius of the search (m).
k – The number of nearest neighbors to be used for calculating the interpolated value. Defaults to
9.covariance –
The covariance function, based on the distance between points. This parameter can take one of the following values:
matern_12: \(\sigma^2\exp\left(-\frac{d}{\rho} \right)\)matern_32: \(\sigma^2\left(1+\frac{\sqrt{3}d}{ \rho}\right)\exp\left(-\frac{\sqrt{3}d}{\rho} \right)\)matern_52: \(\sigma^2\left(1+\frac{\sqrt{5}d}{ \rho}+\frac{5d^2}{3\rho^2}\right) \exp\left(-\frac{ \sqrt{5}d}{\rho} \right)\)cauchy: \(\sigma^2 \left(1 + \frac{d}{\rho} \right)^{-1}\)gaussian: \(\sigma^2 \exp \left(-\frac{d^2}{ \rho^2} \right)\)spherical: \(\sigma^2 \left(1 - \frac{3d}{2r} + \frac{3d^3}{2r^3} \right) \left(\frac{d}{r} \le 1 \right)\)linear: \(\sigma^2 \left(1 - \frac{d}{r} \right) \left(\frac{d}{r} \le 1 \right)\)
drift_function –
The drift (trend) function to be used for universal kriging. This parameter can take one of the following values:
linear: \(m(x,y,z) = \beta_0 + \beta_1 x + \beta_2 y + \beta_3 z\)quadratic: \(m(x,y,z) = \beta_0 + \beta_1 x + \beta_2 y + \beta_3 z + \beta_4 x^2 + \beta_5 y^2 + \beta_6 z^2 + \beta_7 xy + \beta_8 xz + \beta_9 yz\)
Defaults to
None(simple kriging with known mean 0).sigma – The sill (magnitude) parameter \(\sigma\) of the covariance function. Determines the overall scale (maximum covariance).
alpha – The range parameter \(\rho\). Determines how quickly the covariance decays with distance. Units must match the distance units used internally (geodetic/ECEF -> meters, pure Cartesian -> user units).
nugget – Nugget effect (added to the covariance matrix diagonal). Accounts for measurement error or unresolved microscale variability. Must be \(\ge 0\).
within – If true, the method ensures that the neighbors found are located around the point of interest (prevents extrapolation).
num_threads – Number of threads to use.
0uses all available,1disables parallelism (useful for debugging).
- Returns:
The interpolated value and the number of neighbors used in the calculation.
Note
If
drift_functionisNone, simple kriging with known mean 0 is applied.If
drift_functionis provided, universal kriging augments the system with the corresponding trend basis functions.alphacorresponds to the range parameter \(\rho\) controlling spatial correlation extent.