This article provides a Surfer script for replacing the Z values of blanked nodes in a grid file with 0. This does not change the Blank Value in the grid header.
To run this script:
- Copy the text below, or download the attached BAS file: Blank0.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer\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.
*********
'Blank0.bas replaces the blanking value in a grid file with 0. 'The new grid is saved to a new grid file "<filepath>\<filename>_Blank0.grd" 'A contour map is created from the new grid. Sub Main 'Use existing Surfer instance with a Plot1 window. 'Set surf = GetObject(,"Surfer.application") 'Set plot = surf.Documents("Plot1") 'Open a new Surfer instance. Set surf = CreateObject("Surfer.Application") Set plot = surf.Documents.Add(srfDocPlot) surf.Visible=True Set shapes = plot.Shapes Set grid = surf.NewGrid 'grid.LoadFile(surf.Path+"\samples\DemoRectBlank.grd",False) 'Select the [.GRD] file and its directory path gridFilePath = GetFilePath( , "grd",surf.Path+"\samples\","Open Grid File",0) 'Load the selected [.GRD] file grid.LoadFile(gridFilePath,False) Debug.Print "Processing GridRow:" For row=1 To Grid.NumRows() For col=1 To Grid.NumCols() 'If Grid.IsBlanked(row,col) = True Then Grid.SetNode(row,col) = 0 If Grid.IsBlanked(row,col) Then Grid.SetNode(row,col,0) 'Grid.SetNode(row,col) = 0.0 'Grid.SetNode(row,col,0) 'End If Next col Debug.Print row; If row Mod 20 = 0 Then Debug.Print Next row 'Append "_Blank0_" to the outup [.GRD] filename gridFilePath = Left(gridFilePath,InStrRev(gridFilePath,".")-1) & "_Blank0" & Mid(gridFilePath,InStrRev(gridFilePath,"."),4) Debug.Print 'CR 'Save the modified Grid Grid.SaveFile(gridFilePath, srfGridFmtS7) 'Create a ContourMap using this grid shapes.AddContourMap(gridFilePath) End Sub
Updated November 08, 2018
Comments
0 comments
Please sign in to leave a comment.