How can I overlay maps and set new limits and scale via Surfer automation?

To overlay maps and set the new limits and scale, set the OverlayMaps command to a new object, and then set the limits and scale of the new object. A full script showing this process is below.


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 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. 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 1, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


  • 0
    Kien Pham

    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?

  • 0
    Leslie McWhirter

    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.



    Edited by Leslie McWhirter
Please sign in to leave a comment.