*.xSize*and

*.ySize*parameter of the

*GridData3*method.

'Grids the data setting the grid spacing in the X and Y directions (xSize, ySize) SurferApp.GridData3 (DataFile:=DataFile, xSize:=0.2, ySize:=0.2, OutGrid:=OutGrid2) Set MapFrame2 = Plot.Shapes.AddContourMap(GridFileName:=OutGrid2)

In Surfer 12 and previous, the *GridData* method did not have parameters for setting grid spacing, but it did let you specify the number of grid nodes. Calculate the number of grid nodes for the desired grid spacing with the following equation:

**Number of grid nodes = ( (max - min) / spacing )**

To get the data min and max for X and Y, read the data file in the worksheet and calculating the statistics for the X and Y columns.

Set Wks = SurferApp.Documents.Open(file1) Set WksRange = Wks.Columns(Col1:=1, Col2:=2) Set WksStatistics = WksRange.Statistics dataxmin = WksStatistics.Minimum(1) dataxmax = WksStatistics.Maximum(1) dataymin = WksStatistics.Minimum(2) dataymax = WksStatistics.Maximum(2) wks.Close

The next issue is setting the XY min max of the grid file. To get a grid spacing exact, the max - min interval should be evenly divisible by the grid spacing. Set the actual min and max values to be evenly divisible by the grid spacing (5 in this example) to insure that the interval is also evenly divisible:

gridspacing = 5 gridxmin = gridspacing * Int(dataxmin/gridspacing) gridxmax = gridspacing * (1 + Int(dataxmax/gridspacing)) gridymin = gridspacing * Int(dataymin/gridspacing) gridymax = gridspacing * (1 + Int(dataymax/gridspacing))

Then calculate the number of rows and columns (grid nodes in X and Y):

ncol = 1 + (gridxmax-gridxmin)/gridspacing nrow = 1 + (gridymax-gridymin)/gridspacing

Now you're ready to plug these into the *GridData* function:

SurferApp.GridData(file1, NumCols:=ncol, NumRows:=nrow, _ xmin:=gridxmin, xmax:=gridxmax, ymin:=gridymin, ymax:=gridymax, _ Algorithm:=srfKriging, Outgrid:=outfile1)

*Updated September 27, 2017*

## 0 Comments