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:
- Copy the script below, or download the attached BAS file: background.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- 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.
*********
'============================================================================ 'BACKGROUND.BAS ' '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 Path=SurferApp.Path+"\Samples\" 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
Comments
Please sign in to leave a comment.