Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Golang library for geospatial prediction and mapping via ordinary kriging

License

NotificationsYou must be signed in to change notification settings

lvisei/go-kriging

Repository files navigation

GoDocGo Report CardLicense: MIT

Golang Multi-Goroutine spatial interpolation algorithm library for geospatial prediction and mapping via ordinary kriging.

Based on @oeo4b'skriging.js refactoring and optimized the algorithm and added some new features.

This is exponential grid output png examples.

Fitting a Model

The train method with the new ordinaryKriging fits your input to whatever variogram model you specify - gaussian, exponential or spherical - and returns a variogram variable.

import"github.com/lvisei/go-kriging/ordinarykriging"funcmain() {sigma2:=0alpha:=100ordinaryKriging:=ordinarykriging.NewOrdinary(values,x,y)variogram=ordinaryKriging.Train(ordinarykriging.Spherical,sigma2,alpha)}

Predicting New Values

Values can be predicted for new coordinate pairs by using the predict method with the new ordinaryKriging.

import"github.com/lvisei/go-kriging/ordinarykriging"funcmain() {// ...// Pair of new coordinates to predictxnew:=0.5481ynew:=0.4455tpredicted:=ordinaryKriging.predict(xnew,ynew)}

Variogram and Probability Model

According tosakitam-gis, 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 )

The variance parameter α of the prior distribution for w should be manually set, according to:

  • w ~ N(w|0, αI)

Using the fitted kernel function hyperparameters and setting K as the Gram matrix, the prior and likelihood for the gaussian process become:

  • y ~ N(y|0, K)
  • t|y ~ N(t|y, σ2I)

The variance parameter σ2 of the likelihood reflects the error in the gaussian process and should be manually set.

Other

kriging-wasm example - Test example used by wasm compiled with go-kriging algorithm code.

go-kriging-service - Call the REST service written by the go-kriging algorithm package, which supports concurrent calls by multiple users, and has a simple logging and fault-tolerant recovery mechanism.

License

This package implement @oeo4b's kriging.js, a JavaScript library that is alsoMIT-licensed.

About

Golang library for geospatial prediction and mapping via ordinary kriging

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp