This article began as a major course project during my third year at university and was originally published on CSDN. I put a great deal of effort into it, so I decided to preserve it here.
Kriging is relatively complex, but it can produce high-quality interpolation results. Implementing it in code requires a detailed understanding of the calculations involved.
Performing Kriging in ArcGIS
Import Point Data

Choose Geostatistical Wizard from the Geostatistical Analyst toolbar. If the toolbar is not visible, right-click an empty area of the toolbar region and enable Geostatistical Analyst.
Select the Data

Choose Ordinary Kriging

Model-fitting Interface
This screen is important and corresponds to the concepts described in the ArcGIS documentation. The fitted curve in the upper-left corner is what the C# implementation will reproduce, and the plotted points must also be calculated.

Inspect the Variogram Model Types
Open the Type menu to choose among spherical, exponential, Gaussian, and other models. Selecting a different type changes the fitted curve on the left. The ArcGIS documentation describes each model.

View the Interpolation Result

Error Analysis

Understanding the ArcGIS Kriging Documentation
Open the ArcGIS help, search for “kriging,” and select “How Kriging works.”

Calculate Pairwise Semivariance
The formula is , where is the distance between points and and becomes the x-coordinate. The calculated semivariance becomes the y-coordinate.
With 100 points, calculating semivariance between every point and the other 99 produces a large amount of data, including duplicate pairs, and makes fitting inefficient. The documentation recommends reducing the results by distance bins—for example, calculating a mean for 0–10, 10–20, 20–30, and so on.
This produces the points shown below: red points are the original pairwise results, and blue points are the bin means.

Fit the Points to Obtain the Range and Sill
The model is fitted primarily to the blue points. In the equations, is the nugget, is the partial sill, and or is the practical range. The nugget is commonly assumed to be zero in this fitting process.

Spherical Model

Exponential Model

Gaussian Model

Assuming , the spherical equation has three unknowns, whereas the Gaussian and exponential models have two. Because the fitting process must be implemented in C#, I chose the simpler exponential model:
Fitting yields and , producing a semivariogram model that can be used in the interpolation step.
Estimate the Value at an Unknown Point
The ArcGIS help did not describe the remaining calculation in detail, so I obtained the procedure from a competition PDF. Let be the fitted model above, and let be the distance between points and .
Define for constructing matrix and vector . Matrix is calculated from the known sample points:
Vector contains between the unknown location and every known point:
Matrix and vector yield vector , where is the weight assigned to known point : .
The elevation at is then calculated as , where is the elevation at known point .
This estimates the elevation at one unknown point. Matrix is constant for the same set of samples, so estimating additional locations only requires recalculating vector .
Beyond Coordinates