This article contains a sample script for creating a GRD file with user defined grid spacing.
To run this script:
- Copy the script below, or download the attached BAS file: GridSpacing.bas.
Note: If you're running Surfer 12 or an earlier version, download GridSpacing_S12.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 16.
- 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.
- Change the values in the User-defined variables section as desired.
- Click Script | Run to run the script.
'===================================================== 'GridSpacing.bas '===================================================== 'Creates a GRD file with user defined grid spacing. 'This script is for only Surfer 13 and later. Surfer 12 and earlier did not have the grid spacing option. '===================================================== Sub Main 'Gets the existing Surfer instance. If Surfer isn't open, it opens it. On Error GoTo createnew Set SurferApp = GetObject(, "Surfer.Application") On Error GoTo 0 GoTo skipnew createnew: Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True skipnew: '===================================== 'User-defined variables '===================================== 'Specifies the file path where the data file to grid resides path1 = "c:\program files\golden software\surfer 16\samples\" 'Specifies the data file infile1 = path1+"demogrid.dat" 'Specifies the file to save the output grid to outfile1 = path1+"demogrid.grd" 'Specifies the grid spacing gridspacing = 0.1 '===================================== 'Creates a plot document window Set Plot = SurferApp.Documents.Add 'Grids the data SurferApp.GridData4(DataFile:=infile1, xSize:=gridspacing, ySize:=gridspacing, Outgrid:=outfile1) 'Creates a contour map Plot.Shapes.AddContourMap(outfile1) End Sub
Updated November 8, 2018