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:
- Copy the text below, or download the attached BAS file: BlankValue.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 15\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- 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.
- 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 Debug.Clear 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 Shapes.AddContourMap(gridfilepath) End Sub
Updated October 10, 2017