The Grid Project feature is now available via automation! The Grids | Edit | Project command creates a new grid in a different coordinate system from a grid in an existing map layer or a grid file. See below for specifications on how to use the new objects and methods in automation:
A new IApplication object (IApplication5) was extended from IApplication4 to include the following new method:
GridProject
Parameter | Type | Required/Optional | Default | Description |
---|---|---|---|---|
InGrid | String | Required | N/A | The filepath of the input grid to be projected. |
InCS | String | Optional | InGrid's coordinate system, if specified | The coordinate system of the input grid that is being projected. |
OutGrid | String | Optional | "out.grd" | The filepath of the output grid that was projected. |
OutFmt | SrfGridFormat | Optional | Surfer 7 Binary Grid | The file extension (or type) for the output grid that was projected. |
OutCS | String | Required | N/A | The coordinate system that the input grid will be projected to. |
NumRows | Number | Optional | The number of rows in the input grid | The number of rows in the output grid. |
NumCols | Number | Optional | The number of columns in the input grid | The number of columns in the output grid. |
ResampleMethod | SrfResampleMethod | Optional | srfBilinear | The method we use to determine how the Z values for the output grid willl be calculated. |
Syntax
object.GridProject(InGrid:="C:\Users\David\Downloads\input.grd", InCS:="World Geodetic System 1984", OutGrid:="C:\Users\David\Downloads\output.grd", OutFmt:=srfGridFmtS7, OutCS:=WGS72 UTM zone 01N", NumRows:=5, NumCols:=7, ResampleMethod:=srfBilinear)
Remarks
In the UI, there is a "Resize output grid" checkbox. Instead of including another parameter to represent this, resizing the output grid will be false if neither NumRows nor NumCols are specified. If either of NumRows or NumCols is specified, then resizing the output grid will occur.
The InCS and OutCS parameters can be a name, token, or valid WKT for a coordinate system.
Example
Sub Main Dim Surfer As Object Set Surfer = CreateObject("Surfer.Application") Surfer.Visible = True 'project "Colorado.grd" from it's internal Coordinate System to "Bonne Projection", save to "output.grd" Surfer.GridProject(Surfer.Path + "\Samples\Colorado.grd", "Bonne Projection", OutGrid:="C:\Users\David\Downloads\output.grd") 'project "Grand Canyon.grd" from "World Geodetic System 1972" to "Eckert IV" (using it's token) using the Cubic Convolution resampling method. The output grid with be 124 x 118 and will be saved to "output.vtk" Surfer.GridProject(Surfer.Path + "\Samples\Grand Canyon.grd", OutCS:="WORLD_ECKERT4", InCS:="World Geodetic System 1972", NumRows:=124, NumCols:=118, ResampleMethod:=srfCubic, _ OutGrid:="C:\Users\David\Downloads\output.vtk", OutFmt:=srfGridFmtVTK) End Sub
Updated January 2021
Comments
0 comments
Please sign in to leave a comment.