HOW TO
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.
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
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).
Article ID:000002830
Get help from ArcGIS experts
Download the Esri Support App