Overlay maps and set new limits and scale via Surfer automation

When multiple map layers are overlaid, the map limits are automatically adjusted to show the full extents of the combined maps.  As a result, the limits and scale often need to be adjusted.  The script below shows how to create 3 maps, overlay them, set the new limits and adjust the map scale.


To run this script:

  1. Copy the script below, or download the attached BAS file: OverlayMaps.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. Press Ctrl+V to paste it into Scripter. 
  6. Click Script | Run to run the script.


Sub Main
    Dim SurferApp, Plot, ContourMapFrame, ContourMap, _ 
        ClassedPostMapFrame, ClassedPostMap, BaseMapFrame, BaseMap, _ 
        Shapes As Object 
    Set SurferApp = CreateObject ("Surfer.Application") 
    SurferApp.Visible = True 
    Set Plot = SurferApp.Documents.Add(srfDocPlot) 
    Set MapFrame1 = Plot.Shapes.AddContourMap (SurferApp.Path+"/samples/demogrid.grd") 
    Set MapFrame2 = Plot.Shapes.AddBaseMap (SurferApp.Path+"/samples/demoslice.bln") 
    Set MapFrame3 = Plot.Shapes.AddImageMap(SurferApp.Path+"/samples/demogrid.grd") 
    MapFrame1.Selected = True 
    MapFrame2.Selected = True 
    MapFrame3.Selected = True 
    Set NewMapFrame = Plot.Selection.OverlayMaps
End Sub 


See also the attached script OverlayMaps.bas, which can also be found in the \Samples\Scripts\ folder in the Surfer installation directory.


Updated November 2021

Was this article helpful?
0 out of 1 found this helpful


Date Votes
  • What do the number 4,7,3,6 mean when you set the limit? I saw there are three map frame objects but four numbers?

  • Hello Kien,

    The four parameters in SetLimits are xMin (4), xMax (7), yMin (3), and yMax (6). These settings are for a single map object (the one with the overlain map layers). You can learn about this command in the Help.




Please sign in to leave a comment.