Interpolate Z from XY
Perform interpolation on XYZ data at a given set of XY values
Minimum Origin Version Required: 9.1 SR0
Command Line Usage
1.interp2 ixy:=[XYZRandomGaus]"XYZ Random Gaussian"!(D,E) ir:=[XYZRandomGaus]"XYZ Random Gaussian"!(A,B,C) method:=rk pts:=3 smooth:=4;
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
|XY Values to Interpolate
|| Specify the input XY range for the given XY values.
|| Specify the input XYZ range for the group of XYZ data.
|| Specify the interpolation method to be used. 8 methods are available.
- rk:Random Kriging
- rc:Renka Renka Cline
- rs:Random Shepard
- tps:Random TPS
- wa:Weight Average
More details can be found in the Algorithm section below.
|| Specify a search radius. Only available when the method is either Random Kriging or Weight Average.
|| Specify a minimum number of points. Only available when the method is Random Kriging.
|| Specify a Kriging or Spline smoothing factor. Only available when the method is either Random Kriging or Spline.
|| Specify a vector as the weight. Only available when the method is Spline.
|Weight Function Locality Factor
|| Specify a weight function locality factor. Only available when the method is Random Shepard.
|Quadratic Interpolant Locality Factor
|| Specify a quadratic interpolant locality factor. Only available when the method is Random Shepard.
|Result of Interpolation
|| Specify where to output the interpolation result.
This X-Function is used to interpolate a group of existing xyz data to find z value for given (x,y), using one of eight (8) methods: Nearest, Random Kriging, Random Renka Cline, Random Shepard, Random TPS, Spline, Triangle and Weight Average.
In order to interpolate z from xy, using the interp2 X-Function:
- In Script Window, run
to open the interp2 dialog box.
- Pick data (x,y) from worksheet as XY Values To Interpolate, and a range of xyz data as Input for interpolation.
- Select a Method from the drop-down menu.
- Assign destination columns as Result of Interpolation.
Interp2 provides estimation of a variable at an unmeasured location from observed values at surrounding locations. There are 8 methods used in X-Function Interp2, the correspondence for each method and algorithm are listed in table below.
||Ordinary Kriging interpolation
|Random Renka Cline
||Triangle-based Renka Cline interpolation
||Modification of Shepard’s method interpolation
||Random TPS interpolation
||Bicubic B-spline interpolation
||Triangle-based Renka Cline interpolation
||Inverse Distance Weighting interpolation
Nearest neighbor interpolation
In the nearest neighbor algorithm, it finds the nearest point of the given to-be-interpolated X and Y values, and then uses this found point's Z value as the interpolated result. This procedure does not include other neighboring points, that will yield a piece-wise-constant interpolation. This algorithm is so simple that its resulting surface is not smooth.
(Random)Ordinary Kriging interpolation
Origin has called this function ocmath_2d_kriging_scat to perform ordinary Kriging interpolation. The basic procedure of ordinary Kriging is described as following.
Assume are a series of observed random points and are the measured values of the series points respectively. At a given point, , which is not measured yet, according to ordinary Kriging, the estimated value, , for this unmeasured point can be derived by a weighted linear combination of the measured points, which can be written as:
where is the weight for its corresponding point.
To get the estimated value, , for the unmeasured point , it needs to figure out the weight for each measured point, which has contribution to the calculation.
First of all, we need to assumed that the random function for the points is stationary, which makes sure the unbiasedness of result. That is to say, the expected value of the following expression needs to be zero.
Obviously, here, where is the mean, so we get .
Secondly, it should satisfy the optimal variance for the error. That is to minimize the variance, which shows as the expression below.
To minimize the above expression, the Lagrange parameter is introduced, and let:
Calculate the partial first derivatives of the above equation with respect to and and get:
Then we get the simplified one:
Then the partial first derivatives can be expanded and rewritten as matrix form,
To solve for the weights, multiply both sides of the matrix form by , the inverse matrix of the matrix, so to get .
The final step is to decide the covariance. For all the above calculations are based on the assumption that the random variables in random function model all have the same mean and variance. Such assumption leads us to the relationship between the model variogram and the model covariance as following.
Put this relationship equation to the partial first derivatives, we can get another form (the matrix form is similar):
In Origin, the power model is used for estimating the varigram, which is:
where , and . can refer to the distance between and , so
In the dialog of this X-Function, when this method is used, corresponds to the Smoothing Factor, and Search Radius (for the search radius) and Minimum Points (minimum points included for interpolation) correspond to the radius and noctMin parameters in function ocmath_2d_kriging_scat respectively.
Random Renka Cline
The algorithm of the Random Renka Cline is based on nag_2d_scat_interpolant (e01sac) function provided by NAG. However, according to the NAG Library: Advice on Replacement Calls for Withdrawn/Superseded Functions, the nag_2d_scat_interpolant (e01sac) is replaced by nag_2d_shep_interp (e01sgc) or nag_2d_triang_interp (e01sjc). Thus, the Random Renka Cline method has the algorithm similar to Triangle method which based on nag_2d_triang_interp (e01sjc), while the latter is recommended due to the smaller maximum interpolation errors could be obtained.
Please refer to the (Random) Shepard for algorithm introduction.
Please refer to the Random TPS for algorithm introduction.
This method based on the nag_2d_spline_fit_scat (e02ddc) which computes a bicubic spline approximation to a set of scattered data.
This method is based on the algorithm in nag_2d_triang_interp (e01sjc), which constructs an interpolating surface through a set of scattered data points , for , using a method due to Renka and Cline. The constructed surface is continuous and has continuous first derivatives.
The weighted average method is based on ocmath_gridding_weighted_average. The unknown value can be calculated from the surrounded true values within the specified search radius r. The interpolate value can be expressed by:
is the distance between and . If there is no value within the search radius, Zp will be missing value. Increasing the search radius means that each point is more interrelated to neighboring points, so to produce a smoother surface that may lose fine details.
Here we offer the comparison of the eight methods. We apply the eight methods to six functions from F1 to F6, which corresponds to exponential peak, cliff surface, saddle surface, gentle peak, steep peak, and sphere surface, respectively. The method is derived from Ref. 2. The interpolation for 1089 points is based on 100 nodes uniform distribution. Mean error and Maximum error are average and max of the difference between real values and interpolated values for 1089 points, respectively. The bar chart for mean error and maximum error are shown below:
- Isaaks and Srivastava. An Introduction to Applied Geostatistics, Chapter 12. Oxford University Press (1989)
- R. J. Renka and A. K. Cline. A Triangle-Based Interpolation Method, Rocky Mountain Journal of Mathematics. 14, 223-237 (1984)
- P. Dierckx. An Algorithm for Surface-Fitting with Spline Functions, IMA Journal of Numerical Analysis. 1, 267-283 (1981)