Change the map background color via Surfer automation

When preparing maps for presentation it can sometimes be helpful to set a background color or pattern to the map area.  For example, this could be used to indicate bodies of water on a world map.  The sample script below shows how to do this via automation.

To run this script:

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


'This script demonstrates the following:
'	Grid a sample data file
'	Create a contour map
'	Create checkered background color
'												SKP 9/99 Surfer 7
Sub Main
	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True
	Dim Doc As Object
	Set Doc = SurferApp.Documents.Add
	SurferApp.GridData (DataFile:=path+"demogrid.dat", _
		ShowReport:=False, Algorithm:=srfKriging, OutGrid:=path+"sample.grd")
	Dim MapFrame As Object
	Set MapFrame = Doc.Shapes.AddContourMap(GridFileName:=Path+"Colorado.grd")
	'Changes the map background
	MapFrame.BackgroundFill.Pattern = "Diagonal Cross"
	MapFrame.BackgroundFill.BackColorRGBA.Color = srfColorRed
	MapFrame.BackgroundFill.ForeColorRGBA.Color = srfColorIceBlue
End Sub


Updated November 2021

Was this article helpful?
3 out of 4 found this helpful



Please sign in to leave a comment.