GridAssignNoData

GridAssignNoData assigns the NoData value to grid nodes inside or outside specified boundaries. Returns a Boolean. If the value is 'True', the grid was assigned the NoData value. If the value is 'False', the grid was not assigned any NoData values.

Syntax

object.GridAssignNoData( InGrid, NoDataFile, OutGrid, OutFmt, Layer, SelectedPolysOnly, Side, OutGridOptions )

Parameter

Type

Required/

Optional

Default

Description

InGrid

String

Required

 

This provides the path and file name of the input grid file.

NoDataFile

String

Optional

""

This provides the path and file name of the input blanking file [.BLN] file. A BLN file is required, see Remarks

OutGrid

String

Required

""

This provides the path and file name of the output grid file.

OutFmt

SrfGridFormat

Optional

 

This specifies the output grid format.

Layer

VectorBaseLayerObject

Optional

 

The vector base layer whose polygons can be used as the polygon boundary for assigning NoData.

SelectedPolysOnly

Boolean

Optional

False

If True, only selected polygons from the Layer parameter will be used for the polygon boundary. If False, all polygons from the Layer parameter will be used for the polygon boundary.

Side

SrfNoDataPolygonSide

Optional

srfNoDataPolyMixed

Specifies the side of each polygon (inside or outside) in the polygon boundary to be used for assigning NoData.

OutGridOptions

String

Optional

""

The Grid Export Options String provides the output option string for the grid format.

Remarks

A Golden Software Blanking File *.BLN is required for the GridAssignNoData method. Any vector file format can be used in the Surfer user interface (UI). Consider,

  • creating a vector base layer with your data file for use as the Layer parameter
  • importing your vector data file and using Export2 to save it as a BLN file for use as the NoDataFile parameter

to use a file format other than BLN with GridAssignNoData.

See Golden Software Blanking File Description for more information on BLN files used for NoDataFile.

If both the Layer and NoDataFile parameters are provided, the GridAssignNoData() method will use the value provided to Layer for the polygon boundary. If neither of these parameters are provided, an error will be raised.

The SelectedPolysOnly and Side parameters only apply to GridAssignNoData if the Layer parameter is provided. If the user provides the NoDataFile parameter instead, the two aforementioned parameters will be ignored.

The Layer parameter must be defined using 'Dim [LayerObject] as Object' before passing Layer object in for the Layer parameter, in order for the GridAssignNoData() method to work correctly. If this 'Dim [LayerObject] as Object' line is not added to the script before passing Layer object in for the Layer parameter, the GridAssignNoData() method will not recognize the value passed in for the Layer parameter as a valid VectorBaseLayer object.

If any other type of object (other than a VectorBaseLayer) is passed in for the Layer parameter, an error is raised.

Example 1

This example demonstrates how to assign the NoData value to the nodes in the base layer in Conifer.grd and saves the grid.

Sub Main

 

Dim Surfer As Object

Set Surfer = GetObject(,"Surfer.Application")

Surfer.Visible = True

Set dirPath = "C:\Downloads"

 

Dim BaseLayer As Object 'This line is required

Set Plot = Surfer.Documents.Open(dirPath + "\SelectedPgon.srf")

 

Set BaseLayer = Plot.Shapes.Item(1).Overlays.Item(2)

BaseLayer.Shapes.StartEditing()

BaseLayer.Shapes.Item("Donut").Select

 

'assigns NoData to Conifer.grd for all nodes in base layer outside of the selected polygons (just the polygon called 'Donut' in this case)

Surfer.GridAssignNoData(Surfer.Path + "\Samples\Conifer.grd", Layer:=BaseLayer, SelectedPolysOnly:=True, Side:=srfNoDataPolyOutside, OutGrid:=dirPath + "\outLayer.grd")

Set MapFrame1 = Plot.Shapes.AddColorReliefMap(GridFileName:=dirPath + "\outLayer.grd")

Example 2

This example demonstrates how to assign the NoDataFile parameter.

'Side' and 'SelectedPolysOnly' parameters would not apply if provided in this case

Surfer.GridAssignNoData(Surfer.Path + "\Samples\Demogrid.grd", NoDataFile:=Surfer.Path + "\Samples\Demorect.bln", OutGrid:=dirPath + "\outFile.grd")

Set MapFrame2 = Plot.Shapes.AddColorReliefMap(GridFileName:=dirPath + "\outFile.grd")

Example 3

This example demonstrates how to assign GridAssignNoData to Diablo.grd, save the file as Blank.grd and save spatial references as a Blue Marble .RSF file and an Esri World file.

Surfer.GridAssignNoData(InGrid:=InGridPath+"Diablo.grd", BlankFile:=Surfer.Path + "\Samples\DemoSlice.bln", OutGrid:=OutGridPath + "Blank.grd", _OutGridOptions:="UseDefaults=1, ForgetOptions=1, SaveRefInfoAsBlueMarbleRSF=1, SaveRefInfoAsESRIWorld=1")

Example 4

This script displays all the methods in the Application object.

Used by: Application object