ProjectCoordinates
The ProjectCoordinates method is used to convert the XY coordinate system of data in a worksheet document. All systems in the Assign Projection dialog are available to this method.
This method allows you to specify a Source Coordinate System and project the X and Y coordinate data to a new Target Coordinate System. The input Source Columns and output Target Columns allow you to either overwrite the original coordinate columns, or write the new coordinates to new columns in you worksheet. For example, this command can be useful if you have coordinate data in latitude and longitude (i.e. Source Coordinate System) and need to project the coordinates to UTM (i.e. Target Coordinate System).
Returns a Boolean. Returns 'True' if the process is successful, else returns 'False'.
Syntax
object.ProjectCoordinates( SourceCS, TargetCS, xSourceCol, ySourceCol, xTargetCol, yTargetCol )
Parameter |
Type |
Required/ Optional |
Default |
Description |
SourceCS |
String |
Required |
This specifies the source coordinate system. |
|
TargetCS |
String |
Required |
This specifies the destination coordinate system. |
|
xSourceCol |
Long |
Required |
This specifies the X axis source column. |
|
ySourceCol |
Long |
Required |
This specifies the Y axis source column. |
|
xTargetCol |
Long |
Optional |
|
This specifies the X axis destination column. |
yTargetCol |
Long |
Optional |
|
This specifies the Y axis destination column. |
Remarks
The syntax for a CS string is the exact name of the coordinate system as it appears in the Assign Coordinate System dialog. For example,
"Asia Pulkovo 1942 / 3-degree Gauss-Kruger zone 25"
"Canada NAD27 / MTM zone 6"
"State Plane 1927 – Georgia East (Meters)"
The ProjectCoordinates method cannot operate on an unreferenced system.
If no X or Y TargetCol is specified these values are assumed to be 0.
Example
This example converts XY coordinates in a data file from European 1950 - UK/Ireland to Europe ETRS89 / ETRS-TM29.
'Declares SurferApp as an object
Dim SurferApp As Object
'Creates an instance of the Surfer Application object and assigns it
'to the variable named "SurferApp"
Set SurferApp = CreateObject("Surfer.Application")
'Makes Surfer visible
SurferApp.Visible = True
'Declares Wks as an object
Dim Wks As Object
'Opens the sample Demogrid.DAT file as a worksheet document
Set Wks = SurferApp.Documents.Open(FileName:=SurferApp.Path+"\Samples\Demogrid.DAT")
'Performs the coordinate conversion
Wks.ProjectCoordinates(SourceCS:="European 1950 - UK/Ireland" , _
TargetCS:="Europe ETRS89 / ETRS-TM29", xSourceCol:=1, _
ySourceCol:=2, xTargetCol:=4, yTargetCol:=5 )
Used by: WksDocument object