logo

img

Knowledgebase Home | Contact Knowledgebase Home | Contact
Search the Knowledgebase Browse by Category
How can I set the grid spacing with the GridData function?
User Opinions
100% thumbs up 0% thumbs down

How would you rate this answer?
Helpful
Not helpful
The GridData method does not have parameters for setting grid spacing, but it does let you specify the number of grid lines. Calculate the number of grid lines for the desired grid spacing with the following equation:

Number of grid lines = ( (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 = surf.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 your case) 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:

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

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

surf.GridData(file1, NumCols:=ncol, NumRows:=nrow, _
    xmin:=gridxmin, xmax:=gridxmax, ymin:=gridymin, ymax:=gridymax, _
    Algorithm:=srfKriging)
Visitor Comments
No visitor comments posted. Post a comment
Related Questions
Attachments
No attachments were found.
Products