GridData2
The GridData2 method is superseded by GridData6. Please consider using the more recent version. GridData2 has been retained for backward compatibility.
GridData2 creates a grid from irregularly spaced XYZ data and can be used to specify the TriangleFileOptions and DataFileOptions parameters.
Grid files are required to create different types of maps, including contour, image, shaded relief, vector, 3D surface, and 3D wireframe. The grid data files are typically randomly spaced files, and this data must be converted into an evenly spaced grid before using. GridData returns a Boolean value. It returns 'True' if the grid file is successfully created, otherwise returns 'False'.
The GridData2 command should be used instead of GridData when the worksheet being loaded is an Excel file where the sheet name needs to be specified. It can also be used to specify any data import options when loading a data file.
Syntax
object.GridData2( DataFile, xCol, yCol, zCol, ExclusionFilter, DupMethod, xDupTol, yDupTol, NumCols, NumRows, xMin, xMax, yMin, yMax, Algorithm, ShowReport, SearchEnable, SearchNumSectors, SearchRad1, SearchRad2, SearchAngle, SearchMinData, SearchDataPerSect, SearchMaxEmpty, FaultFileName, BreakFileName, AnisotropyRatio, AnisotropyAngle, IDPower, IDSmoothing, KrigType, KrigDriftType, KrigStdDevGrid, KrigVariogram, MCMaxResidual, MCMaxIterations, MCInternalTension, MCBoundaryTension, MCRelaxationFactor, ShepSmoothFactor, ShepQuadraticNeighbors, ShepWeightingNeighbors, ShepRange1, ShepRange2, RegrMaxXOrder, RegrMaxYOrder, RegrMaxTotalOrder, RBBasisType, RBRSquared, OutGrid, OutFmt, SearchMaxData, KrigStdDevFormat, DataMetric, LocalPolyOrder, LocalPolyPower, TriangleFileName, TriangleFileOptions, DataFileOptions )
Parameter |
Type |
Required/ Optional |
Default |
Description |
DataFile |
String |
Required |
|
This provides the path and file name of the XYZ data file name |
xCol |
Long |
Optional |
1 (Column A) |
This provides the column containing X values, column A = 1. |
yCol |
Long |
Optional |
2 (Column B) |
This provides the column containing Y values, column B = 2. |
zCol |
Long |
Optional |
3 (Column C) |
This provides the column containing Z values, column C = 3. |
ExclusionFilter |
Variant |
Optional |
|
This provides the Boolean search to exclude values. |
DupMethod |
Variant |
Optional |
|
This provides the method for eliminating duplicates, the SrfDupMethod enumeration can be used for this parameter. |
xDupTol |
Variant |
Optional |
|
This provides the separation distance of X values to be considered duplicates. |
yDupTol |
Variant |
Optional |
|
This provides the separation distance of Y values to be considered duplicates. |
NumCols |
Variant |
Optional |
|
This provides the grid line geometry number of columns. |
NumRows |
Variant |
Optional |
|
This provides the grid line geometry number of rows. |
xMin |
Variant |
Optional |
|
This provides the grid line geometry minimum X value. |
xMax |
Variant |
Optional |
|
This provides the grid line geometry maximum X value. |
yMin |
Variant |
Optional |
|
This provides the grid line geometry minimum Y value. |
yMax |
Variant |
Optional |
|
This provides the grid line geometry maximum Y value. |
Algorithm |
Variant |
Optional |
|
This provides the gridding method (kriging, etc.), the SrfGridAlgorithm enumeration can be used for this parameter. |
ShowReport |
Variant |
Optional |
|
This enables the show grid report, the report is only shown if ShowReport is true and Surfer is visible. |
SearchEnable |
Variant |
Optional |
|
This enables No Search (use all of the data). It is one of the search options. |
SearchNumSectors |
Variant |
Optional |
|
This provides the number of sectors to search. |
SearchRad1 |
Variant |
Optional |
|
This provides the search ellipse radius 1. It is one of the search options. |
SearchRad2 |
Variant |
Optional |
|
This provides the search ellipse radius 2. It is one of the search options. |
SearchAngle |
Variant |
Optional |
|
This provides the search ellipse angle. It is one of the search options. |
SearchMinData |
Variant |
Optional |
|
This provides the minimum number of data in all sectors (node is blanked if the data surrounding the node are less than this number). |
SearchDataPerSect |
Variant |
Optional |
|
This provides the maximum number of data to use from each sector. |
SearchMaxEmpty |
Variant |
Optional |
|
This provides the number of blank nodes if more than this many sectors are empty. |
FaultFileName |
Variant |
Optional |
|
This provides the file containing fault traces. |
BreakFileName |
Variant |
Optional |
|
This provides the file containing breaklines. |
AnisotropyRatio |
Variant |
Optional |
|
This provides the anisotropy ratio used for various algorithms. |
AnisotropyAngle |
Variant |
Optional |
|
This provides the anisotropy angle used for various algorithms. |
IDPower |
Variant |
Optional |
|
This specifies the inverse distance to a power, power number. |
IDSmoothing |
Variant |
Optional |
|
This specifies the inverse distance to a power, smoothing factor. |
KrigType |
Variant |
Optional |
|
This specifies the kriging type (point or block. The SrfKrigType enumeration can be used for this parameter. |
KrigDriftType |
Variant |
Optional |
|
This specifies the kriging drift type (none, linear, or qu adratic), the enumeration can be used for this parameter. |
KrigStdDevGrid |
Variant |
Optional |
|
This provides the output grid of kriging standard deviations |
KrigVariogram |
Variant |
Optional |
|
This specifies the kriging variogram model. KrigVariogram may contain an array of VarioComponent objects. If this parameter is not specified the default Linear variogram is used. |
MCMaxResidual |
Variant |
Optional |
|
This specifies the minimum curvature maximum residual. |
MCMaxIterations |
Variant |
Optional |
|
This specifies the minimum curvature maximum number of iterations. |
MCInternalTension |
Variant |
Optional |
|
This specifies the minimum curvature internal tension factor. |
MCBoundaryTension |
Variant |
Optional |
|
This specifies the minimum curvature boundary tension factor. |
MCRelaxationFactor |
Variant |
Optional |
|
This specifies the minimum curvature relaxation factor. |
ShepSmoothFactor |
Variant |
Optional |
|
This specifies the modified Shepard's method smoothing factor. |
ShepQuadraticNeighbors |
Variant |
Optional |
|
This specifies the modified Shepard's method quadratic neighbors. |
ShepWeightingNeighbors |
Variant |
Optional |
|
This specifies the modified Shepard's method weighting neighbors. |
ShepRange1 |
Variant |
Optional |
|
This specifies the modified Shepard's method anisotropy range 1. |
ShepRange2 |
Variant |
Optional |
|
This specifies the modified Shepard's method anisotropy range 2. |
RegrMaxXOrder |
Variant |
Optional |
|
This specifies the polynomial regression maximum X order. |
RegrMaxYOrder |
Variant |
Optional |
|
This specifies the polynomial regression maximum Y order. |
RegrMaxTotalOrder |
Variant |
Optional |
|
This specifies the polynomial regression maximum total order. |
RBBasisType |
Variant |
Optional |
|
This specifies the radial basis function type (inverse multiquadric, multilog, multiquadric, natural cubic spline, or thin plate spline), theSrfBasisTypeenumeration can be used for this parameter. |
RBRSquared |
Variant |
Optional |
|
This specifies the radial basis function correlation coefficient |
OutGrid |
String |
Optional |
"" |
This provides the path and file name of the output grid file. |
OutFmt |
Optional |
srfGridFmtS7 |
This provides the output grid file format, |
|
SearchMaxData |
Variant |
Optional |
|
This specifies the maximum number of data to use from all sectors. This one of the search criteria. |
KrigStdDevFormat |
Variant |
Optional |
|
This specifies the standard deviation grid file format, theenumeration can be used for this parameter |
DataMetric |
Variant |
Optional |
|
This specifies one of thedata metricoptions, the SrfDataMetric enumeration can be used for this parameter. |
LocalPolyOrder |
Variant |
Optional |
|
This specifies the local polynomial order. |
LocalPolyPower |
Variant |
Optional |
|
This specifies the local polynomial power (0 to 20). |
TriangleFileName |
Variant |
Optional |
|
This provides the name of the file to contain the triangulation - the format is determined by the file name extension. |
TriangleFileOptions |
Variant |
Optional |
|
This specifies the triangle export options dependent on the graphic format specified for export |
DataFileOptions |
Variant |
Optional |
|
This specifies data import options |
Remarks
Please refer to the gridding advanced options dialogs for more information on using gridding options. Some of the above options require certain parameters to be used and some parameters cannot be used with other parameters. For example, SearchEnable must be enabled to successfully use the seven parameters (Search...) that follow it. Another example is if the natural neighbor gridding method is selected for Algorithm, KrigVariogram should not be set. Since this method contains so many parameters, try using named arguments for this method (see examples below). There is no need to preload the file into the worksheet.
Example 1
This example uses GridData2. The Grid Report was turned on in this example to display the correct sheet being used.
Sub Main
Dim SurferApp As Object
Set SurferApp = CreateObject("Surfer.Application")
SurferApp.Visible = True
Dim Doc As Object
Set Doc = SurferApp.Documents.Add(srfDocPlot)
SurferApp.GridData2("c:\temp\book1.xls",DataFileOptions:="sheet=Test", _
ShowReport:=True,OutGrid:="c:\temp\book1.grd"), _
Doc.Shapes.AddContourMap(GridFileName:="c:\temp\test.grd")
End Sub
Example 2
This example uses GridData2 to grid the data using a specific worksheet in an Excel file and creates a grid file.
'Grids the data using a specific sheet in a workbook and creates a grid file
SurferApp.GridData2(DataFile:="c:\temp\book1.xlsx",DataFileOptions:="sheet=sheet2", _
Algorithm:=1, ShowReport:=False, OutGrid:="c:\temp\sheet2.grd")
Example 3
This example shows how to use GridData2 to export a Triangle File with file-specific options
'Grids the data using Triangulation with Linear Interpolation and also exports vector triangles
SurferApp.GridData2(DataFile:="c:\temp\demodata.dat", Algorithm:=srfTriangulation, _
ShowReport:=False, OutGrid:="c:\temp\Demogrid.grd", TriangleFile:= _
"c:\temp\Demogrid_Triangles.bln", TriangleFileOptions:="SaveScalingInfo=1, _
BreakApartCompoundAreas=0")
Example 4
This example shows how to use GridData2 to grid a table from an Access database
'Grids the Access database using Kriging
SurferApp.GridData2 (DataFile:="C:\temp\sample.mdb", _
DataFileOptions:="Table=elevation", xcol:=4, ycol:=3, zcol:=5, _
Algorithm:=srfKriging, OutGrid:="C:\temp\Access.grd")
Example 5
This script displays all the methods in the Application object.
Used by: Application object