English

How To: Transform datums between ATS 1977 and NAD 1983 (CSRS98) in New Brunswick

Summary

National Transformation version 2 (NTv2) is a geographic (datum) transformation method. It was originally created by the Geodetic Survey Division of Geomatics Canada.

Canada, Australia, and New Zealand use NTv2 to convert between geographic coordinate systems (datums). ArcGIS does not support all NTv2 grids.

This document demonstrates how to use VBA to add support for unsupported transformations.

Procedure

The following VBA script adds support for a new Canadian grid called NB7783v2.gsb. It converts between ATS 1977 and NAD 1983 (CSRS98) in New Brunswick. For a list of supported grid files at version 8.1 refer to the document referenced in the Related Information section.

  1. In ArcMap, click Tools > Macros > Macros. Type in a name for the macro, like transform, and click Create.
  2. In the VBA Editor, copy the code below into the subroutine.

    Code:
    '-- Start by getting a handle on the current FocusMap
    Dim pMxDoc As IMxDocument
    Set pMxDoc = Application.Document

    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    '-- Set the input spatial reference to ATS 1977
    Dim pATS77 As IGeographicCoordinateSystem
    Dim pSpRefFrom As ISpatialReference
    Dim pSpRefEnv As SpatialReferenceEnvironment
    Set pSpRefEnv = New SpatialReferenceEnvironment

    Set pATS77 = pSpRefEnv.CreateGeographicCoordinateSystem(esriSRGeoCS_ATS1977)
    Set pSpRefFrom = pATS77
    pSpRefFrom.SetFalseOriginAndUnits -180, -90, 1000000

    '-- Set the output spatial reference to NAD 1983 (CSRS98)
    Dim pNAD83 As IGeographicCoordinateSystem
    Dim pSpRefTo As ISpatialReference

    Set pNAD83 = pSpRefEnv.CreateGeographicCoordinateSystem(esriSRGeoCS_NAD1983CSRS98)
    Set pSpRefTo = pNAD83
    pSpRefTo.SetFalseOriginAndUnits -180, -90, 1000000

    '-- Define the custom geographic transformation
    Dim pNTv2 As IGridTransformation
    Set pNTv2 = New NTv2Transformation

    '-- A grid-based transformation has its data name set to dataset_<country>/<filename>
    pNTv2.Name = "ATS77_To_NAD83_New_Brunswick"
    pNTv2.GridDatasetName = "dataset_canada/NB7783v2"
    pNTv2.PutSpatialReferences pATS77, pNAD83
    pNTv2.Load 'Loads the grid into memory. When finished with the grid, used the Unload method.

    '-- Add the transformation to the operation set
    Dim pGTSet As IGeoTransformationOperationSet
    Set pGTSet = New GeoTransformationOperationSet
    '-- The Map uses IMapGeographicTransformations to access the geogtrans
    Dim pMapGeo As IMapGeographicTransformations
    Set pMapGeo = pMap
    Set pGTSet = pMapGeo.GeographicTransformations

    pGTSet.Set esriTransformForward, pNTv2

    '-- Now refresh the map
    DoEvents
    pMxDoc.ActiveView.Refresh

  3. Run the script.
  4. In ArcMap, open the data frame properties.
  5. Switch to the Coordinate Systems tab.
  6. Click Transformations.

    Note:
    Make sure the 'Convert from' list box and 'Into' dropdown boxes list ATS 1977 and NAD 1983 (CSRS). It doesn't matter whether you're converting from ATS 1977 or NAD 1983 (CSRS98).

  7. Select 'ATS77_To_NAD83_New_Brunswick' from the Using dropdown box and click OK.
  8. Click OK on the Data Frame Properties dialog box.

Related Information