The Point Sample command samples Z values from a grid at any point. To perform the operation, create a data file with X and Y coordinates for the points you'd like to sample. See below for specifications on how to use the new objects and methods in automation:
PointSample()
Parameter | Type | Required/Optional | Default | Description |
---|---|---|---|---|
InGrid | String | Required | N/A | The path to the input grid that will be used to calculate the Z value for the provided XY locations |
XYData | String | Required | N/A | The path to the data file that provides the XY locations whose Z values will be calculated |
XCol | Number | Optional | First used column in XYData | The column that stores the X locations from XYData |
YCol | Number | Optional | XCol + 1 (i.e. first used column in XYData + 1) | The column that stores the Y locations from XYData |
StoreZCol | Number | Optional | The first empty column in XYData after used columns (i.e. columns B-G are full, StoreZCol will be column H) | The column where the calculated Z values will be stored in XYData |
Syntax
Set Worksheet = object.PointSample(InGrid:="C:\Users\David\Downloads\Demogrid.grd", XYData:="C:\Users\David\Downloads\WellLocations.dat", XCol:=1, YCol:=3, ZCol:=4)
Remarks
This method will return the worksheet document that represents the original XYData file but with the new Z values (stored in StoreZCol) added. This worksheet being returned will be the same (or at least very close to the same) as the worksheet that is opened with the PointSample command in the UI.
Example
Sub Main Dim Surfer As Object Set Surfer = GetObject(,"Surfer.Application") Surfer.Visible = True 'use the default X, Y, and Z columns, which should be A, B, and D respectively Set Wks = Surfer.PointSample(Surfer.Path + "\Samples\Demogrid.grd", Surfer.Path + "\Samples\Demogrid.dat") 'explicitly set the X, Y, and Z columns, which should now be B, C, and H respectively Set Wks2 = Surfer.PointSample(Surfer.Path + "\Samples\Demogrid.grd", Surfer.Path + "\Samples\Demogrid.dat", xCol:=1, YCol:=2, StoreZCol:=5) 'make sure that the Worksheet Document being returned is valid Wks2.SaveAs("C:\Users\David\Downloads\zOutput.dat") Wks2.Close() End Sub
Updated January 2021
Comments
0 comments
Please sign in to leave a comment.