Follow

How can I update the header limits in my DEM grid in Surfer Scripter?

This article contains a sample script for editing the X and Y min/max values in the grid header for DEM and DDF (SDTS) files.

To run this script:

  1. Copy the script below, or download the attached BAS file: GridHeader.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 14\Scripter.
  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.
     

*********

'GridHeader.bas - Lets you edit the XY min max values in the grid header,
'and saves it to a new GRD file.
' Works with DEM and DDF (SDTS) files.


Sub Main
	Set surf = CreateObject("surfer.application")
	file1 = GetFilePath("c:\incoming\demogrid.grd", _
		"GRD;DEM;DDF", _
		surf.Path+"\samples\", _
		"Enter GRD / DEM File Name")
	If file1 = "" Or Dir(file1) = "" Then End
	Set grid1 = surf.NewGrid
	grid1.LoadFile (file1, headeronly:=False)
	With grid1
		gridxmin = .xMin
		gridxmax = .xMax
		gridymin = .yMin
		gridymax = .yMax
	End With 'grid1

	Begin Dialog UserDialog 430,182,"Enter XY Min Max" ' %GRID:10,7,1,1
		GroupBox 20,21,290,154,"Grid Header",.GroupBox1
		TextBox 100,35,190,21,.TextBox1
		TextBox 100,70,190,21,.TextBox2
		TextBox 100,105,190,21,.TextBox3
		TextBox 100,140,190,21,.TextBox4
		Text 40,40,40,14,"xMin",.xMin
		Text 40,75,40,14,"xMax",.xMax
		Text 40,110,40,14,"yMin",.yMin
		Text 40,145,40,14,"yMax",.yMax
		OKButton 330,28,90,21
		CancelButton 330,70,90,21
	End Dialog
	Dim dlg As UserDialog

	'Initializes the dialog controls
	dlg.TextBox1 = CStr(gridxmin)
	dlg.TextBox2 = CStr(gridxmax)
	dlg.TextBox3 = CStr(gridymin)
	dlg.TextBox4 = CStr(gridymax)
	Dialog dlg

	With grid1
		.xMin = Val(dlg.textbox1)
		.xMax = Val(dlg.textbox2)
		.yMin = Val(dlg.textbox3)
		.yMax = Val(dlg.textbox4)
	End With
	file2 = GetFilePath(Left(file1,Len(file1)-4)+"+_New.grd","GRD", _
		surf.Path+"\samples\","Save File",2)

	grid1.SaveFile(file2,srfGridFmtS7)
	MsgBox(file2&" has been created.")

End Sub

 

Updated February 13, 2017

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

0 Comments

Please sign in to leave a comment.