NewGridMathInput
GridMath2 performs grid-to-grid and grid-to-constant math operations. It creates a new grid file that transforms the Z values of a single grid file or combines Z values from multiple grid files. The output grid file is based on a mathematical function of the form f (A ,B, ...), where A, B, ... are input grid files. The GridMath2 command should be used instead of GridMath command when more than two grids need to be combined or when the Z value of NoData grid nodes need to be changed.
Before calling the GridMath2 command, the input grids must be referenced in a NewGridMathInput object. Each grid needs its own NewGridMathInput object.
The NewGridMathInput is used to create an array of grid files. Returns a GridMathInput object.
Syntax
object.NewGridMathInput(GridFileName, VariableName, BlankHandling, RemapValue)
Parameter |
Type |
Required/ Optional |
Default |
Description |
GridFileName |
String |
Required |
|
This provides the path, file name, and any options for the input grid files. This is defined with the NewGridMathInput. |
VariableName |
String |
Required |
|
Sets the variable name for this grid file. |
BlankHandling |
Optional |
srfGMBlankOutput |
This sets the output NoData method to either assign the NoData value to the output or set a Z value for NoData nodes. |
|
RemapValue |
Double |
Optional |
0 |
This sets the blanked value when BlankHandling is set to srfGMBlankRemap. |
Example 1
This example demonstrates how to assign three grids to the GridMathInput object.
'Create the first grid
SurferApp.GridData(DataFile:=SurferApp.Path+"\Samples\demogrid.dat", xCol:=1, _
yCol:=2, zCol:=3, Algorithm:=srfKriging, ShowReport:=False, _
OutGrid:="c:\temp\demogrida.grd", OutFmt:=srfGridFmtS7)
'Create the second grid
SurferApp.GridData(DataFile:=SurferApp.Path+"\Samples\demogrid.dat", xCol:=1, _
yCol:=2, zCol:=3, Algorithm:=srfKriging, ShowReport:=False, _
OutGrid:="c:\temp\demogridb.grd", OutFmt:=srfGridFmtS7)
'Create the third grid
SurferApp.GridData(DataFile:=SurferApp.Path+"\Samples\demogrid.dat", xCol:=1, _
yCol:=2, zCol:=3, Algorithm:=srfKriging, ShowReport:=False, _
SearchEnable:=False, SearchRad1:=5, SearchRad2:=5, _
OutGrid:="c:\temp\demogridc.grd", OutFmt:=srfGridFmtS7)
'Create the InGrids() array with 3 grid files
Dim InGrids (1 To 3) As IGridMathInput
'The first input grid will use Variable="A", second Variable = "B", third Variable="blanked"
'The first and second grids will use NoData values.
'The third grid will remap NoData nodes To 1000.
Set InGrids(1) = SurferApp.NewGridMathInput(GridFileName:= _
"c:\temp\demogrida.grd", VariableName:="A")
Set InGrids(2) = SurferApp.NewGridMathInput(GridFileName:= _
"c:\temp\demogridb.grd", VariableName:="B")
Set InGrids(3) = SurferApp.NewGridMathInput(GridFileName:= _
"c:\temp\demogridc.grd", VariableName:="blanked", _
BlankHandling:=srfGMBlankRemap, RemapValue:=1000)
'Use the GridMath2 with the function A-B+blanked
SurferApp.GridMath2(Function:="A-B+blanked", InputGrids:=InGrids, _
OutGrid:="c:\temp\GridCombine.grd", OutFmt:=srfGridFmtS7)
'Create a contour map from the output grid
Plot.Shapes.AddContourMap("c:\temp\GridCombine.grd")
Example 2
This script demonstrates how to assign data values to the NoData nodes in a single grid.
'Create the grid with NoData values
SurferApp.GridData(DataFile:=SurferApp.Path+"\Samples\demogrid.dat", xCol:=1, _
yCol:=2, zCol:=3, Algorithm:=srfKriging, ShowReport:=False, _
SearchEnable:=True, SearchRad1:=5, SearchRad2:=5, _
OutGrid:="c:\temp\demogridc.grd", OutFmt:=srfGridFmtS7)
'Create a contour map from the grid and move it to the left of the page
Set ContourMap1 = Plot.Shapes.AddContourMap("c:\temp\demogridc.grd")
ContourMap1.Left = -6
'Create the InGrids() array with 1 grid files
Dim InGrids (1 To 1) As IGridMathInput
'The first input grid will use variable="blanked"
Set InGrids(1) = SurferApp.NewGridMathInput(GridFileName:="c:\temp\demogridc.grd", _
VariableName:="blanked", BlankHandling:=srfGMBlankRemap, RemapValue:=1000)
'Use the GridMath2 with the function "blanked"
SurferApp.GridMath2(Function:="blanked", InputGrids:=InGrids, _
OutGrid:="c:\temp\ChangeBlank.grd", OutFmt:=srfGridFmtS7)
'Create a contour map from the output grid
Plot.Shapes.AddContourMap("c:\temp\ChangeBlank.grd")
Example 3
This script displays all the methods in the Application object.
Used by: Application object