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 – Array of shape
(n, 3)or(n, 2)containing observation coordinates. Here n is the number of observations and each row represents a coordinate in the order x, y, and optionally z. If the matrix shape is(n, 2), the z-coordinate is assumed to be zero. The coordinate system depends on the instance configuration: Ifecef=True, coordinates are in the Cartesian coordinate system (ECEF). Otherwise, coordinates are in the geodetic system (longitude, latitude, 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.