|
Surfer 8 - Calculate the Z
Value At Any XY Point in a Surfer Grid File
Introduction
After calculating a grid from XYZ data in Surfer,
you may want to calculate the Z value of additional XY points within the map.
Surfer provides several tools for this task.
- Grid | Residuals interactive method.
- Grid.Interpolation in automation.
- The Grid Node Editor.

Calculate the Z value of any XY data point.
Work Interactively with Grid | Residuals
The Grid | Residuals menu command provides
a way to calculate the difference between the grid value and data value at any
XY location. This procedure is designed to measure how well a grid matches a
data set, or to calculate the difference between a trend surface grid and the
raw data. It can be used to return the grid value for XY points that have an
unknown Z value. Surfer uses a bilinear interpolation method to calculate Z
values at points that do not coincide with grid nodes.
In the Surfer worksheet, create or import a list
of XY data points. Fill a blank column with 0's using the Data | Transform menu
command, using the formula
C = 0
where C is the blank column letter. Save the
changes, close the worksheet window, and open or switch to a plot window. Choose
the Grid | Residuals menu command, specify the GRD file, the data file,
and the column to contain the residual values. Click OK, and the worksheet
displays the data file with the residuals column.

Specify XYZ and residual columns.
The Residuals command calculates the
residuals by subtracting the grid value from the data value, so the negative of
the grid value is returned when the values in the data column are 0. To reverse
the sign of the values, select the Residuals column, and choose the Data |
Transform menu commands and enter the formula
D = -D
where D is the Residuals column. Save the changes
with the worksheet File | Save command.
Automate Z Calculations with
Grid.Interpolate
The Surfer automation interface provides another
way to return the Z value in a grid file. The Interpolate method of the Grid
object returns the Z value at the specified XY location. It uses bilinear
interpolation to return Z values at points that do not coincide with grid nodes.
zvalue =
grid1.Interpolate(x:=2.2, y:=3.4)
The grid1 object can be a GRD file or the grid
information in a SRF file containing a map based on a GRD file.
The GridInterpolate.bas
script on our ftp site runs in the Surfer Scripter program and calculates the Z
values at the XY locations specified in a data file.
Z Value at Grid Nodes
For the special case of XY data points that
coincide with the grid nodes, there are interactive and file-based methods to
return the Z values.
- Open a GRD file with the File | Open or
Grid | Grid Node Editor menu commands. Click within the map or scroll
with the arrow keys to display the X, Y, and Z values. In addition, Z values
can be modified and saved to a file.

Use the Grid Node Editor to view Z values coincident with the grid nodes.
- Choose the Grid | Convert menu commands
to convert any existing GRD file into a GS ASCII GRD file or an ASCII XYZ
DAT file. Open the GRD file in a text editor to view the values. The DAT
file can be opened in a text editor or in the Surfer worksheet.
Summary
Surfer offers many useful tools for querying the
grid file for Z values, including interactive methods via the user interface,
and automated methods via the scripting language.
If you have any questions about Surfer or this
article, contact us at surfersupport@goldensoftware.com.
Back
to Newsletter Index
|