kriging.js is a Javascript library for mapping and predicting spatial data using the kriging algorithm. This library allows one to model and map spatial data.
The easiest way to get started is to download the Javascript library (or link directly to krigingjs.com/kriging.js) and attach it to your html code. Then, to train a model with coordinates (x, y) and values t on parameters σ2 and α:
var model = "exponential"; var sigma2 = 0, alpha = 100; var fitModel = kriging.train(t, x, y, model, sigma2, alpha);
To predict points at a new point in space (xnew, ynew):
var tnew = kriging.predict(xnew, ynew, fitModel);
-
Creating Maps
-
Documentation
-
Probability Model
The model used is a 2-dimensional gaussian process, y, with a prior on the parameters of the kernel function. One of a variety of different kernel functions (or variogram models) generate the Gram matrix K. The variance σ2 of the noise process is adjustable, providing a smoothing effect by increasing the uncertainty of the likelihood t.
y ~ N(0, K) t|y ~ N(t|y, σ2I)
-
Variogram
The various variogram models can be interpreted as kernel functions for 2-dimensional coordinates a, b and parameters nugget, range, sill and A. Reparameterized as a linear function, with w = [nugget, (sill-nugget)/range], this becomes:
Gaussian: k(a,b) = w[0] + w[1] * ( 1 - exp{ -( ||a-b|| / range )2 / A } ) Exponential: k(a,b) = w[0] + w[1] * ( 1 - exp{ -( ||a-b|| / range ) / A } ) Spherical: k(a,b) = w[0] + w[1] * ( 1.5 * ( ||a-b|| / range ) - 0.5 * ( ||a-b|| / range )3 )
Bayesian regression is used to estimate the parameters with the prior:
w ~ N(w|0, αI)
-
Mapping methods
Grid and vector based mapping methods are available within the instantiated kriging object.