Golden Software Blog

Helping you learn more about the latest product information, tips, tricks, techniques, and customer stories so you can visualize data and communicate results with ease.

Scripter Example: Grid Plot Script

Scripter is a useful tool that is integrated into Surfer and allows you to automate repetitive tasks which you perform often. This can save time and ensure consistent properties or procedures are applied across many maps. Scripter is also available in Grapher and MapViewer.

This week, I will be presenting a script that takes each grid file in a specified folder and plots each of those grid files in a separate Surfer file. This would be useful if you want to quickly create contours of your grid data with the same formatting properties.

Here is how this script actually works! For each grid file (*.grd) in the specified directory, the script creates a new window, makes a contour map using the grid file, saves and closes the Surfer (*.srf) file. This process repeats for the next grid file in the directory until contour maps have been created for each grid file in the folder.

When you initially open a grid file in Surfer using the File | Open command, it will simply show the point locations for each grid point. These points appear at their X, Y location and contain the data attribute that has been gridded.  In the example shown below (Colorado.grd), the grid contains the XY points as well as the elevation at each point.

Input Grid File Colorado.grd

From the grid file shown above, the script creates a contour map (Colorado.srf), shown below. The contour maps are shown with the Colormap (Land.clr) to display elevation (high=white, low=green). 

Output Contour Map Colorado.srf

With this script you can quick and easily map contour maps from your grid files. Below are examples of the grid files and contour maps that were created in just seconds using this script. If you have to contour many grid files for a project, this script could be very useful.

Below are four additional example grid files and their contour maps made using this script:

Example file Demogrid.grd and resulting contour map.

Example file ( Conifer.grd) and contour map.

The grid file show below (Concentration.grd) is shown below with blanked grid values in blue. These points in the grid file will be blanked in the resulting contour map and not displayed. The blank feature can be useful to limit the extent of the area that a grid file displays. For more information on blanking a grid file, check out this Knowledge Base article: LINK.

Concentration_grid.png  Concentration.grd.png
Grid file and contour map with blanked grid values.

Using the attached script, you will only need to change the file path to point the script to the folder containing your grid files. In the User Variables section of the script, simply change the file path to the appropriate folder where your grid files are located (highlighted in yellow below).

 ''''''''''''' User Variables ''''''''''''''''''

'You must enter the path to the grid files and the name of the BLN file

file_directory  = "C:\Users\GS_User\Desktop\Example"   'make sure has a trailing \

file_extension  = "grd"  'no "." preceding the extension 


With this change made, the script will look in this folder for an grid files (*
.grd) and plot them as contour maps. It is also possible to further format your contour map using this script; however, those changes are beyond the scope of this blog post.


Add a text object to the map with the grid file name:

Creates a text string with the grid file name and assigns it to the variable named "Text"
SetText = Shapes.AddText(x:=8, y:=10, Text:=grid_file)

Set the color fill of the contours:
'Assigns the Land Colormap to the foreground fill.        
ContourMap.FillForegroundColorMap.LoadFile("C:\Program Files\Golden Software\Surfer 11\ColorScales\Land.clr")

'Apply contour map fill changes
ContourMap.ApplyFillToLevels(FirstIndex:=1, NumberToSet:=2, NumberToSkip:=0)
ContourMap.FillContours = True

You can download the example script and grid files used in this post here:


Below are some additional resources for using Scripter to edit a contour map.

The Knowledge Base contains additional information to map changes to a contour map using Scripter:

How can I change the contour label properties?

How can I change the contour map fill color?

How can I calculate the volume or area between contours?

Download Scripts for Surfer, Grapher, and MapViewer from our website:

Golden Software provides a number of useful sample scripts that product owners can download for free from our website, here:

Script Examples are available inside each program (Surfer, Grapher, MapViewer, and Voxler):

In the program, go to Help | Contents to open the program help files.  Click on the Contents tab to see all of the help books.  Open the program Automation book, near the bottom of the list.  There are script examples and information on scripting located here.

There are sample scripts located by in the program's installation directory. The default location for Surfer 11, Grapher 10, MapViewer 7, and Voxler 3 is
C:\Program Files\Golden Software\<program name>\Samples\Scripts, where <program name> would be substituted with either Surfer 11, Grapher 10, MapViewer 7, or Voxler 3.

Online Support Forum:

The support forums  are a great resource to find past script examples, or request script help from the experts of each program.




No comments made yet. Be the first to submit a comment
Monday, 18 June 2018

Captcha Image

Subscribe To Our Blog

Most Popular

Over the years, one of the most common questions asked is “How can I get my contour map out of Surfe...
For more than 20 years, Surfer mapping software has been used by representatives of nearly all indus...
This week's new feature series is a tutorial on how to use the new coordinate system dialogs in MapV...

Exceeding expectations

Go to top