Creating a Variogram with Scripter

The Variogram object represents a variogram. A Variogram object is a type of Shape object. Create a new Variogram using the Shapes collection’s AddVariogram method. The AddVariogram method returns a reference to a Variogram object. Use the properties and methods of the Variogram object to access information about the computed variogram and to modify the options.

A VarioComponent object represent one component of a variogram model. When you use the Kriging algorithm to create a grid file, you can specify the variogram model to use by passing an array of VarioComponent objects to the Application object’s GridData method. Create a VarioComponent by calling the Application object’s NewVarioComponent method. Use the Variogram object’s Model property to obtain the array of VarioComponent objects used by a variogram.

The following subroutine creates a Variogram object, and then creates a grid file using the computed variogram components.

Sub GridWithComputedVariogram(plot As Object,

' Create a variogram.

Set v = plot.Shapes.AddVariogram (

 

' Create a grid using the computed variogram

plot.Application.GridData DataFile:=datafile, Algorithm := SurferAppKriging, _

KrigVariogram := v.Model, ShowReport := False, OutGrid := grid

 

' Delete the variogram

v.Delete

End Sub

 

The next subroutine creates two VarioComponent objects and creates a grid based on these variogram components.

Sub GridWithStaticVariogram(plot As Object, datafile As String, grid As String)

' Get the Application object

Set SurferApp = plot.Application

 

'Create two VarioComponent objects and store them in an array

Dim components(1 To 2) As Object

Set components(1) = SurferApp.NewVarioComponent(SurferAppVarNugget,1.0,2.0,3.0)

Set components(2) = SurferApp.NewVarioComponent(SurferAppVarLinear,1.0,2.7,1.5)

 

'Create a grid using the two variogram components

SurferApp.GridData DataFile:=datafile, Algorithm := SurferAppKriging, _

KrigVariogram := components, ShowReport := False, OutGrid := grid

End Sub

 

Finally, the following Main procedure demonstrates how you might use the preceding subroutines:

Sub Main

' Start Surfer, set the default directory, and create a plot document

Set SurferApp = CreateObject("Surfer.Application")

SurferApp.Visible = True

SurferApp.DefaultFilePath = SurferApp.Path + "\samples"

Set plot = SurferApp.Documents.Add(srfDocPlot)

 

' Create a grid using a pre-determined variogram model

GridWithStaticVariogram plot, "demogrid.dat, VarioDemo1

 

' Create a grid using a computed variogram model

GridWithComputedVariogram plot, "demogrid.dat, VarioDemo2

 

' Create contour maps to compare the two grids

plot.Shapes.AddContourMap "VarioDemo1"

plot.Shapes.AddContourMap "VarioDemo2"

 

End Sub

See Also

Automation Examples