This document is archived and information here might be outdated.  Recommended version.


Creating a custom vertical coordinate system (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with spatial references > Creating a custom vertical coordinate system

Creating a custom vertical coordinate system


Summary
This topic shows two methods to define a custom vertical coordinate system (VCS).

About creating a custom vertical coordinate system

The ISpatialReferenceFactory interface allows you to create the Datum, VerticalDatum, and LinearUnit component parts. These components can also be created using a similar Define method available on their classes.
  • The following code example creates a gravity-related VCS that uses a vertical datum:
[C#]
private IVerticalCoordinateSystem CreateVerticalCoordinateSystem()
{

    // Set up the SpatialReferenceEnvironment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    Type factoryType=Type.GetTypeFromProgID(
        "esriGeometry.SpatialReferenceEnvironment");
    System.Object obj=Activator.CreateInstance(factoryType);
    ISpatialReferenceFactory3 spatialReferenceFactory=obj as
        ISpatialReferenceFactory3;

    // Creates a gravity-related vertical datum.
    IVerticalDatum verticalDatum=spatialReferenceFactory.CreateVerticalDatum((int)
        esriSRVerticalDatumType.esriSRVertDatum_Taranaki);

    // Because a VCS can be based upon Datum or VerticalDatum, IHVDatum is used 
    // when defining a VCS.
    IHVDatum hvDatum=verticalDatum as IHVDatum;
    ILinearUnit linearUnit=spatialReferenceFactory.CreateUnit((int)
        esriSRUnitType.esriSRUnit_Meter)as ILinearUnit;

    // The direction is set to  - 1 and the VerticalShift is set to 40.
    IVerticalCoordinateSystemEdit verticalCoordinateSystemEdit=new
        VerticalCoordinateSystemClass();
    object name="New VCoordinateSystem";
    object alias="VCoordinateSystem alias";
    object abbreviation="abbr";
    object remarks="Test for options";
    object usage="New Zealand";
    object hvDatumObject=hvDatum as object;
    object unitObject=linearUnit as object;
    object verticalShift=40 as object;
    object positiveDirection= - 1 as object;

    verticalCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref
        remarks, ref usage, ref hvDatumObject, ref unitObject, ref verticalShift,
        ref positiveDirection);
    IVerticalCoordinateSystem verticalCoordinateSystem =
        verticalCoordinateSystemEdit as IVerticalCoordinateSystem;

    return verticalCoordinateSystem;


}
[VB.NET]
Private Function CreateVerticalCoordinateSystem() As IVerticalCoordinateSystem
    
    ' Set up the SpatialReferenceEnvironment.
    ' SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    
    Dim factoryType As Type=Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment")
    Dim spatialReferenceFactory As ISpatialReferenceFactory3=CType(Activator.CreateInstance(factoryType), ISpatialReferenceFactory3)
    
    ' Creates a gravity-related vertical datum.
    Dim verticalDatum As IVerticalDatum=spatialReferenceFactory.CreateVerticalDatum(CInt(esriSRVerticalDatumType.esriSRVertDatum_Taranaki))
    
    ' Because a VCS can be based upon Datum or VerticalDatum, IHVDatum is used
    ' when defining a VCS.
    Dim hvDatum As IHVDatum=TryCast(verticalDatum, IHVDatum)
    Dim linearUnit As ILinearUnit=CType(spatialReferenceFactory.CreateUnit(CInt(esriSRUnitType.esriSRUnit_Meter)), ILinearUnit)
    
    ' The direction is set to  - 1 and the VerticalShift is set to 40.
    Dim verticalCoordinateSystemEdit As IVerticalCoordinateSystemEdit=New VerticalCoordinateSystemClass()
    Dim Name As Object="New VCoordinateSystem"
    
    ' Note: Alias is a reserved keyword in VB .NET. To use it as a variable name, encase it in brackets [ ].
    
    Dim [Alias] As Object="VCoordinateSystem alias"
    Dim abbreviation As Object="abbr"
    Dim remarks As Object="Test for options"
    Dim usage As Object="New Zealand"
    Dim hvDatumObject As Object=TryCast(hvDatum, Object)
    Dim unitObject As Object=TryCast(linearUnit, Object)
    Dim verticalShift As Object=TryCast(40, Object)
    Dim positiveDirection As Object=TryCast( -1, Object)
    
    verticalCoordinateSystemEdit.Define(Name, [Alias], abbreviation, remarks, usage, hvDatumObject, unitObject, verticalShift, positiveDirection)
    Dim verticalCoordinateSystem As IVerticalCoordinateSystem=TryCast(verticalCoordinateSystemEdit, IVerticalCoordinateSystem)
    
    Return verticalCoordinateSystem
    
End Function
  • The following code example creates an ellipsoid-based VCS:
[C#]
private IVerticalCoordinateSystem CreateEllipsoidBasedVerticalCoordinateSystem()
{
    // Set up the SpatialReferenceEnvironment.
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    Type t=Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
    System.Object obj=Activator.CreateInstance(t);
    ISpatialReferenceFactory3 spatialReferenceFactory=obj as
        ISpatialReferenceFactory3;

    // Creates an ellipsoid-based datum.
    IDatum datum=spatialReferenceFactory.CreateDatum((int)
        esriSRDatumType.esriSRDatum_WGS1984);

    // Because a VCS can be based upon Datum or VerticalDatum, IHVDatum is used 
    // when defining a VCS.
    IHVDatum hvDatum=datum as IHVDatum;
    ILinearUnit linearUnit=spatialReferenceFactory.CreateUnit((int)
        esriSRUnitType.esriSRUnit_Foot)as ILinearUnit;

    //Direction is again positive down, while the vertical shift is 0.4839.
    IVerticalCoordinateSystemEdit verticalCoordinateSystemEdit=new
        VerticalCoordinateSystemClass();
    object name="WGS84 vcs";
    object alias="WGS84 ellipsoid";
    object abbreviation="w84 3d";
    object remarks="WGS84 ell-based vcs";
    object usage="everywhere!";
    object hvDatumObject=hvDatum as object;
    object unitObject=linearUnit as object;
    object verticalShift=0.4839 as object;
    object positiveDirection= - 1 as object;

    verticalCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref
        remarks, ref usage, ref hvDatumObject, ref unitObject, ref verticalShift,
        ref positiveDirection);
    IVerticalCoordinateSystem verticalCoordinateSystem =
        verticalCoordinateSystemEdit as IVerticalCoordinateSystem;

    return verticalCoordinateSystem;
}
[VB.NET]
Private Function CreateEllipsoidBasedVerticalCoordinateSystem() As IVerticalCoordinateSystem
    
    ' 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 spatialReferenceFactory As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3=obj
    
    ' Creates an ellipsoid-based datum.
    Dim datum As IDatum=spatialReferenceFactory.CreateDatum(CInt(esriSRDatumType.esriSRDatum_WGS1984))
    
    ' Because a VCS can be based upon Datum or VerticalDatum, IHVDatum is used
    ' when defining a VCS.
    Dim hvDatum As IHVDatum=TryCast(datum, IHVDatum)
    Dim linearUnit As ILinearUnit=CType(spatialReferenceFactory.CreateUnit(CInt(esriSRUnitType.esriSRUnit_Foot)), ILinearUnit)
    
    ' Direction is again positive down, while the vertical shift is 0.4839.
    Dim verticalCoordinateSystemEdit As IVerticalCoordinateSystemEdit=New VerticalCoordinateSystemClass()
    Dim Name As Object="WGS84 vcs"
    
    ' Note: Alias is a reserved keyword in VB .NET. To use it as a variable name, encase it in brackets [ ].
    Dim [Alias] As Object="WGS84 ellipsoid"
    Dim abbreviation As Object="w84 3d"
    Dim remarks As Object="WGS84 ell-based vcs"
    Dim usage As Object="everywhere!"
    Dim hvDatumObject As Object=TryCast(hvDatum, Object)
    Dim unitObject As Object=TryCast(linearUnit, Object)
    Dim verticalShift As Object=TryCast(0.4839, Object)
    Dim positiveDirection As Object=TryCast( -1, Object)
    
    verticalCoordinateSystemEdit.Define(Name, [Alias], abbreviation, remarks, usage, hvDatumObject, unitObject, verticalShift, positiveDirection)
    Dim verticalCoordinateSystem As IVerticalCoordinateSystem=TryCast(verticalCoordinateSystemEdit, IVerticalCoordinateSystem)
    
    Return verticalCoordinateSystem
    
End Function


See Also:

Creating a predefined vertical coordinate system




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 Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine