Creating a custom geotransformation


Summary
A geotransformation, also known as a geographic (datum) transformation, converts data between two geographic coordinate systems. There could be circumstances where you would create a custom geotransformation. This topic discusses custom geotransformations.

About custom geotransformations

Although hundreds of geotransformations are already defined and available, you may have a case where a custom geotransformation must be defined. This can occur when a transformation is not yet included in ArcGIS or the transformation parameters are not available publicly.
The code example in this topic defines a custom geotransformation between the Abidjan 1987 and WGS 1984 geographic coordinate systems. The transformation parameter values are for display purposes only and do not accurately convert data between Abidjan 1987 and WGS 1984.
A geotransformation is always defined in a particular direction. That is, the parameter values are designed to convert data from the input, or source, geographic coordinate system to the output, or target, geographic coordinate system. You must match that directionality when defining the geotransformation. Depending on where the geotransformation will be used later, you may need to provide an esriTransformDirection. All methods supported by geotransformation are bi-directional; they can also be used to convert data from the target geographic coordinate system to the source geographic coordinate system.
See the following code example:
[C#]
private void CustomGT()
{

    // Initialize a new spatial reference environment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.

    Type factoryType = Type.GetTypeFromProgID(
        "esriGeometry.SpatialReferenceEnvironment");
    System.Object obj = Activator.CreateInstance(factoryType);
    ISpatialReferenceFactory2 pSRF = obj as ISpatialReferenceFactory2;

    // Initialize and create the input and output coordinate systems.
    IProjectedCoordinateSystem2 pPCSin = new
        ESRI.ArcGIS.Geometry.ProjectedCoordinateSystemClass();
    IProjectedCoordinateSystem2 pPCSout = new
        ESRI.ArcGIS.Geometry.ProjectedCoordinateSystemClass();
    pPCSin = (IProjectedCoordinateSystem2)pSRF.CreateProjectedCoordinateSystem((int)
        esriSRProjCSType.esriSRProjCS_Abidjan1987UTM_30N);
    pPCSout = (IProjectedCoordinateSystem2)pSRF.CreateProjectedCoordinateSystem((int)
        esriSRProjCSType.esriSRProjCS_WGS1984UTM_30N);

    // Retrieve the geographic coordinate systems from the two projected 
    // coordinate systems.
    IGeographicCoordinateSystem2 pGCSto = (IGeographicCoordinateSystem2)
        pPCSout.GeographicCoordinateSystem;
    IGeographicCoordinateSystem2 pGCSfrom = (IGeographicCoordinateSystem2)
        pPCSin.GeographicCoordinateSystem;

    // Initialize and create an appropriate geographic transformation.
    ICoordinateFrameTransformation pCFT = new CoordinateFrameTransformationClass();
    pCFT.PutParameters(1.234,  - 2.345, 658.3, 4.3829,  - 2.48591, 2.18943, 2.48585);
    pCFT.PutSpatialReferences(pGCSfrom, pGCSto);
    pCFT.Name = "Custom GeoTran";

    // The SpatialReferenceEnvironment has a GeoTransformationOperationSet that you
    // can use to maintain a list of active geographic transformations. 
    // Once you add a geographic transformation to the operation set, many operations
    // can access the transformations. 
    // Add the transformation to the operation set.
    IGeoTransformationOperationSet pGTSet = pSRF.GeoTransformationDefaults;

    // Always add a geographic transformation in both directions. 
    pGTSet.Set(esriTransformDirection.esriTransformForward, pCFT);
    pGTSet.Set(esriTransformDirection.esriTransformReverse, pCFT);

}
[VB.NET]
Private Sub CustomGT()
    
    
    ' Set up the SpatialReferenceEnvironment.
    ' SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    
    Dim t As Type = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment")
    Dim obj As System.Object = Activator.CreateInstance(t)
    Dim pSRF As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3 = obj
    
    ' Initialize and create the input and output coordinate systems.
    Dim pPCSin As IProjectedCoordinateSystem2 = New ESRI.ArcGIS.Geometry.ProjectedCoordinateSystemClass()
    Dim pPCSout As IProjectedCoordinateSystem2 = New ESRI.ArcGIS.Geometry.ProjectedCoordinateSystemClass()
    pPCSin = DirectCast(pSRF.CreateProjectedCoordinateSystem(CInt(esriSRProjCSType.esriSRProjCS_Abidjan1987UTM_30N)), IProjectedCoordinateSystem2)
    pPCSout = DirectCast(pSRF.CreateProjectedCoordinateSystem(CInt(esriSRProjCSType.esriSRProjCS_WGS1984UTM_30N)), IProjectedCoordinateSystem2)
    
    ' Retrieve the geographic coordinate systems from the two projected
    ' coordinate systems.
    Dim pGCSto As IGeographicCoordinateSystem2
    Dim pGCSfrom As IGeographicCoordinateSystem2
    pGCSfrom = DirectCast(pPCSin.GeographicCoordinateSystem, IGeographicCoordinateSystem2)
    pGCSto = DirectCast(pPCSout.GeographicCoordinateSystem, IGeographicCoordinateSystem2)
    
    ' Initialize and create an appropriate geographic transformation.
    Dim pCFT As ICoordinateFrameTransformation
    pCFT = New CoordinateFrameTransformationClass()
    pCFT.PutParameters(1.234, -2.345, 658.3, 4.3829, -2.48591, 2.18943, 2.48585)
    pCFT.PutSpatialReferences(pGCSfrom, pGCSto)
    pCFT.Name = "Custom GeoTran"
    
    ' The SpatialReferenceEnvironment has a GeoTransformationOperationSet that you
    ' can use to maintain a list of active geographic transformations.
    ' Once you add a geographic transformation to the operation set, many operations
    ' can access the transformations.
    ' Add the transformation to the operation set.
    Dim pGTSet As IGeoTransformationOperationSet
    pGTSet = pSRF.GeoTransformationDefaults
    
    ' Always add a geographic transformation in both directions.
    pGTSet.[Set](esriTransformDirection.esriTransformForward, pCFT)
    pGTSet.[Set](esriTransformDirection.esriTransformReverse, pCFT)
    
End Sub


See Also:

Creating a predefined geotransformation
Understanding geotransformations




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
Engine Developer Kit Engine