How can I create a multi-layer cross section using Surfer automation?

This article contains a sample script for creating a multi-layer cross section in Surfer from overlain grid-based map layers. This script is valid in Surfer v15 and above. To run the script, you must have grid files for the tops of various formations.

To run this script:

  1. Copy the script below, or download the attached BAS file: Profile.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. In the USER VARIABLES section of the script, near the top, enter the appropriate file path and grid file names. If you have more than two grids, enter more grid#="name.grd" lines below the existing lines.
  7. Adjust the points for the profile line. Each vertex in your line will require a line like the existing lines:
    pts(n)=# : pts(n+1)=#
    After adjusting the points, set m in the Dim pts(m) As Double line to the n+1 number from the last vertex.
  8. If you have more than two grids, copy and paste line 32, incrementing the 2 in MapFrame2 and grid2 (so the next line would be MapFrame3 and grid3), until maps are created for all of your grids. 
  9. Click Script | Run to run the script.


Sub Main

'Initialize Surfer
	Dim SurferApp, Plot As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True
	Set Plot = SurferApp.Documents.Add

'User-defined variables
'Path where grid files are located
filepath = "c:\temp\"

'Grid files. If there are more than two, add grid3 = ..., grid4 = ..., etc.
grid1 = "layer1.grd"
grid2 = "layer2.grd"

'Create 2 Points for Profile Line (in map units).
'Adjust number in Dimmed pts (should be odd) and number of rows below as needed.
	Dim pts(3) As Double
	pts(0) = 521421.4 : pts(1) = 6811877.6
	pts(2) = 534224.1 : pts(3) = 6792017.0

'Create a contour map and assigns the map frame to the variable "MapFrame"
	Set MapFrame = Plot.Shapes.AddContourMap(filepath+grid1)

'Create another contour map.
'If there are more than two grid files, copy/paste this line, incrementing the 2 in grid2 and MapFrame2
	Set MapFrame2 = Plot.Shapes.AddContourMap(filepath+grid2)

'Overlay maps
	Set NewMapFrame = Plot.Selection.OverlayMaps

'Create Profile object
	Set Profile = NewMapFrame.Profiles.Add(pts)

End Sub


Updated November 7, 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.