ocmath_gridding_weighted_average
Description
This gridding function search neighborhood data points within specified radius. And then estimate the grid point value by weighted averaged method.
Syntax
int ocmath_gridding_weighted_average( int nSize, const double * pX, const double * pY, const double * pZ, int nOutSize, const double * pXout, const double * pYout, double * pZout, double dRadius, int nMethod = WEIGHTED_AVERAGE_SQUARE )
Parameters
- nSize
- [input] the size of the input data
- pX
- [input] double pointer to the array which specify the x-coordinate of the raw data.
- pY
- [input] double pointer to the array which specify the y-coordinate of the raw data.
- pZ
- [input] double pointer to the array which specify the responded z-value of the raw data.
- nOutSize
- [input] the size of the output data.
- pXout
- [input] double pointer to the array which specify the x-coordinate of the grid.
- pYout
- [input] double pointer to the array which specify the y-coordinate of the grid.
- pZout
- [output] double pointer to the array the get the value of the grid.
- dRadius
- [input] searching radius, points within the area will be used for counting the gridding value.
- nMethod
- [input] specify the method used for counting the weight.
Return
Returns OE_NOERROR if succeed, error codes otherwise.
Examples
EX1
//Suppose you have an active worksheet with three columns which are designated as XYZ.
#include <wks2mat.h>
#define NUM_ROWS 11
#define NUM_COLS 11
int ocmath_gridding_weighted_average_ex1(double dRadius, int nMethod)
{
Worksheet wks=Project.ActiveLayer();
Dataset dx(wks, 0), dy(wks, 1), dz(wks, 2);
vector<double> vx = dx, vy = dy, vz = dz;
double dxMin, dxMax;
double dyMin, dyMax;
vx.GetMinMax(dxMin, dxMax);
vy.GetMinMax(dyMin, dyMax);
MatrixLayer ml;
ml.Create();
MatrixObject mo = ml.MatrixObjects(0);
mo.SetXY(dxMin, dyMin, dxMax, dyMax);
mo.SetNumCols(NUM_COLS);
mo.SetNumRows(NUM_ROWS);
matrix& mat = mo.GetDataObject();
vector vXGrid(NUM_ROWS * NUM_COLS), vYGrid(NUM_ROWS * NUM_COLS);
int iRet = ocmath_mat_to_regular_xyz(NULL, NUM_ROWS, NUM_COLS, dxMin, dxMax, dyMin, dyMax, vXGrid, vYGrid, NULL);
if (iRet <= 0) {
printf("Thin plate spline: failed to create XY gridding!\n");
return false;
}
ocmath_gridding_weighted_average(
vx.GetSize(),vx, vy, vz,
NUM_ROWS * NUM_COLS, vXGrid, vYGrid, mat,
dRadius, nMethod);
return 0;
}
Remark
See Also
header to Include
wks2mat.h
Reference
|