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. Additional details about this automation method can be found in the help here: PointSample()
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 November 2021
Comments
Please sign in to leave a comment.