Draw a circle around a point at a defined radius via Surfer automation

Surfer's range ring and buffer features can be used to create shapes with a defined radius.  The RangeRing help page provides a sample script for use of this feature via automation.  Alternatively, the script below creates a circle centered around the XY coordinates defined in a data file.

To run this script:

  1. Copy the script below.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer\Scripter.
  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. Change the Buffer value to the desired radius on line 21.
  7. Click Script | Run to run the script.
     
*********
Sub Main
    Dim SurferApp, Plot, Shapes, Location, Wks, Ellipse As Object
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = True
    Set Plot = SurferApp.Documents.Add(srfDocPlot)
    Set Shapes = Plot.Shapes

    'Specify location of point
    Set Location = Shapes.AddSymbol(x:=4, y:=3)

    'Select which point you want to draw the circle around, export to BLN and view the coordinates of the point
    Location.Select
    Plot.Export("c:\temp\testpoint.bln", True)
    Set Wks = SurferApp.Documents.Open(FileName:="c:\temp\testpoint.bln")
    Xcoord = Wks.Cells(Row:=2, Col:=1)
    Ycoord = Wks.Cells(Row:=2, Col:=2)

    'Add or subtract your buffer value from the point coordinates to create the circle
    Buffer=5
    Set Ellipse = Shapes.AddEllipse(Left:=Xcoord-Buffer, Top:=Ycoord+Buffer, Right:=Xcoord+Buffer, Bottom:=Ycoord-Buffer)
    Wks.Close
End Sub

 

Updated November 2021

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

Comments

0 comments

Please sign in to leave a comment.