PointSample

PointSample computes the interpolated Z value on a gridded surface at given XY locations saved in a data file. Returns the worksheet object in a WksDocument object.

Syntax

object.PointSample( InGrid, XYData, XCol, YCol, StoreZCol)

Parameter

Type

Required/

Optional

Default

Description

InGrid

String

Required

 

The path to the input grid that will be used to calculate the Z value for the provided XY locations.

XYData

String

Required

 

The path to the data file that provides the XY locations whose Z values will be calculated.

xCol

Integer

Optional

First used column in XYData

The column that stores the X locations from XYData.

yCol

Integer

Optional

XCol+1 (i.e. first used column in XYData + 1)

The column that stores the Y locations from XYData.

StoreZCol

Integer

Optional

The first empty column in XYData after used columns (i.e. columns B-G are used, the StoreZCol will be column H)

The column where the calculated Z values will be stores in XY data.

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 user interface.

Example

This example demonstrates how to set the columns for X, Y, and Z values from an existing data file in a new worksheet and save the Excel file.

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:\Downloads\zOutput.dat")

Used by: Application object