Welcome to Golden Software Support

Get mean Nearest neighbor

Comments

6 comments

  • Avatar
    Drew Dudley

    Hello Jose,

    Thank you for posting your question on the Surfer Community forum. You can access the GridStatistics object to get the mean or median of the input grid file. For example, you can use the the following snippet to print the Min, Max, Mean, and Median from the input grid file:

    The HTML Clipboard

    Sub Main
    
        Set SurferApp = GetObject(,"surfer.application")
        SurferApp.Visible = True
    
            'Create a grid object and load in a grid
        Set Grid = SurferApp.NewGrid
        Grid.LoadFile("C:\Program Files\Golden Software\Surfer 15\Samples\demogrid.grd", False)
    
            'Get the stats from the grid
        Set stats = Grid.Statistics
    
            'Print all stats
        With stats
            Debug.Print "Min: " + .Min
            Debug.Print "Max: " + .Max
            Debug.Print "Mean: " + .Mean
            Debug.Print "Median: " + .Median
        End With
        
    End Sub

     

    Thanks,

    Drew Dudley

    Technical Support

    0
    Comment actions Permalink
  • Avatar
    José Pal

    Thank you very much Drew.

    It seems simple, but I having the bug "Not a reference object" in the line 

    Grid.LoadFile("C:\Program Files\Golden Software\Surfer 15\Samples\demogrid.grd", False)

    It also appears when trying using the help example in Surfer Automation Help:

    LoadFile [Grid]

     

    Grid.LoadFile(FileName:=SurferApp.Path+"\Samples\demogrid.grd", HeaderOnly:=True)

     

    Do you know what can be the error?

    Thank you in advance.

     

     

     

    0
    Comment actions Permalink
  • Avatar
    José Pal

    Excuse me Drew, I didn't declared the Grid with Dim Grid As Object instruction. But with the same example:

    rid.LoadFile(FileName:=SurferApp.Path+"\Samples\demogrid.grd", HeaderOnly:=True)

    now the error is: (10099) "ActiveX Automation: no such named parameter."

    while the named parameters exists regarding the Scripter help document.

    Do you find any other error?

     

    0
    Comment actions Permalink
  • Avatar
    Drew Dudley

    Hi Jose,

    With the code snippets above, I am not seeing the same error messages you are. I think it will be best if I was able to see a copy of the actual script you are running. Can you please email a copy to me at drew@goldensoftware.com

    Do any of the scripts run for you from the samples directory (C:\Program Files\Golden Software\Surfer 15\Samples\Scripts)?

    Can you also confirm which version you are running? 

     

    Thanks,

    Drew Dudley

    Technical Support

    0
    Comment actions Permalink
  • Avatar
    José Pal

    Hi Drew,

    I'm using version 11, and reviewing the help document I see that is the method Statistics for Grid object what is missed.

    Instead, with version 15 that method is available and works.

    0
    Comment actions Permalink
  • Avatar
    Drew Dudley

    Hi Jose,

    Thanks for the response. The GridStatistics object was not added to Surfer automation until version 13. So, you are correct that this will not run with Surfer 11. If this is functionality that you need from automation, perhaps you should consider and upgrade to Surfer 15. Your Surfer 11 serial number is most likely eligible for an upgrade for $279 USD. If you are interested, please email your serial number to me at drew@goldensoftware.com so I can verify your eligibility. 

    Thanks,

    Drew Dudley

    Technical Support

     

    0
    Comment actions Permalink

Please sign in to leave a comment.