How do I convert the Blank Value in a grid file header to another value via Surfer automation?

This article provides a Surfer script for converting the Blank Value in a grid file header to another value. This is the Z value that is considered blanked. This does not change the Z values of the blanked nodes.


To run this script:

  1. Copy the text below, or download the attached BAS file: BlankValue.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 16.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.



'Converts the blank value in a grid to a different value. This is the number that Surfer
'considers blanked, so all nodes with this number as the Z value will be blanked in Surfer.

'This is different from Blank0.bas, which simply replaces the Z value
'of blanked nodes with another number, leaving the actual blank value in the grid the same.

Sub Main


	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True

	Set Plot = SurferApp.Documents.Add(srfDocPlot)
	Set Shapes = Plot.Shapes
	Set Grid = SurferApp.NewGrid

'Choose a grid file
	gridfilepath = GetFilePath( , "grd",SurferApp.Path+"\samples\","Open Grid File",0)
	Set Grid2 = Grid.LoadFile(gridfilepath,False)

'Sets the BlankValue of the grid. All nodes with a Z value exactly equal to the BlankValue will be considered blanked by Surfer.
	Grid.BlankValue = -32767

'Saves the grid to a new name
	gridfilepath = Left(gridfilepath,InStrRev(gridfilepath,".")-1) + "_BlankValue.grd
	Grid.SaveFile(gridfilepath, srfGridFmtS7)
	Debug.Print "File saved as ";gridfilepath

'Creates a contour map of new grid

End Sub


Updated November 08, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.