Surfer 6 Grid File Format
Surfer 6 grid files [.GRD] use a layout similar to the ASCII grid format. The only difference is in the identification string and that Surfer 6 grid files are binary.
Data types used in Surfer 6 grid files include:
Type |
Description |
char |
single byte |
short |
16 bit signed integer |
float |
32 bit single precision floating point value |
double |
64 bit double precision floating point value |
The Surfer 6 format has the following layout (byte position is base 1):
Element |
Byte Pos. |
Type |
Description |
id |
1,2,3,4 |
char |
4 byte identification string ‘ DSBB ’ which identifies the file as a Surfer 6 binary grid file. |
nx |
5 |
short |
number of grid lines along the X axis (columns) |
ny |
7 |
short |
number of grid lines along the Y axis (rows) |
xlo |
9 |
double |
minimum X value of the grid |
xhi |
17 |
double |
maximum X value of the grid |
ylo |
25 |
double |
minimum Y value of the grid |
yhi |
33 |
double |
maximum Y value of the grid |
zlo |
41 |
double |
minimum Z value of the grid |
zhi |
49 |
double |
maximum Z value of the grid |
z1, z2 ... … |
57, 61... (step 4 bytes to end of file).... |
float |
Grid data. First value is the lower left node, and the subsequent nodes procede across the row until the end, then up to the second row, etc., until finishing at the upper right node. |
Sample Code
Use the example table to determine what data type you should use for each header value. For example, if you want to get the xMin value of the grid in Scripter, you would insert the following code:
Dim xMin As Double
Open [your filename] For Binary As #1
Get #1,9,xMin
Close #1
Or, if you wanted to load all of the data into an array, you would use this:
Dim xCols As Integer
Dim yRows As Integer
Dim myData() As Single
Open [your filename] For Binary As #1
Get #1,5,xCols
Get #1,7,yRows
ReDim myData((CLng(xCols) * CLng(yRows)) -1)
Get #1,57,myData
Close #1