About creating a predefined vertical coordinate system
The ISpatialReferenceFactory3 interface provides access for creating the VCS available in ArcGIS. You can return a single VCS with ISpatialReferenceFactory3.CreateVerticalCoordinateSystem. Similar to other coordinate system types, a list of VCS can be returned using ISpatialReferenceFactory3.CreatePredefinedVerticalCoordinateSystems.
See the following code example:
[C#] private static void GetVCSList()
{
// 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 srFact3=obj as ISpatialReferenceFactory3;
ISet vcsSet=srFact3.CreatePredefinedVerticalCoordinateSystems();
vcsSet.Reset();
IVerticalCoordinateSystem vcs;
for (int i=0; i < vcsSet.Count; i++)
{
vcs=vcsSet.Next()as IVerticalCoordinateSystem;
Console.WriteLine("VCS Name: {0} (Code: {1})", vcs.Name, vcs.FactoryCode);
}
}
[VB.NET] Private Sub GetVCSList()
' Set up the SpatialReferenceEnvironment.
' SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
' 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)
Dim vcsSet As ISet=spatialReferenceFactory.CreatePredefinedVerticalCoordinateSystems()
vcsSet.Reset()
Dim vcs As IVerticalCoordinateSystem
For i As Integer=0 To vcsSet.Count - 1
vcs=CType(vcsSet.Next(), IVerticalCoordinateSystem)
Console.WriteLine("VCS Name: {0} (Code: {1})", vcs.Name, vcs.FactoryCode)
Next i
End Sub
The list of predefined vertical datums can also be accessed using a method similar to ISpatialReferenceFactory3.CreatePredefinedVerticalCoordinateSystems. The following code example retrieves the list of vertical datums defined by ArcGIS. This method is useful when populating a control with all the available VCS definitions.
[C#] private static void GetVerticalDatumList()
{
// 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);
ISpatialReferenceFactory srFact=obj as ISpatialReferenceFactory;
ISpatialReferenceFactory3 srFact3=srFact as ISpatialReferenceFactory3;
ISet vDatumSet=srFact3.CreatePredefinedVerticalDatums();
vDatumSet.Reset();
IVerticalDatum vDatum;
for (int i=0; i < vDatumSet.Count; i++)
{
vDatum=vDatumSet.Next()as IVerticalDatum;
Console.WriteLine("VDatum Name: {0} (Code: {1})", vDatum.Name,
vDatum.FactoryCode);
}
}
[VB.NET] Private Sub GetVerticalDatumList()
' 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 srFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory=obj
Dim srFact3 As ISpatialReferenceFactory3=srFact
Dim vDatumSet As ISet=srFact3.CreatePredefinedVerticalDatums();
vDatumSet.Reset()
Dim vDatum As IVerticalDatum
For i As Integer=0 To vDatumSet.Count - 1
vDatum=vDatumSet.Next()
Console.WriteLine("VDatum Name: {0} (Code: {1})", vDatum.Name, vDatum.FactoryCode)
Next i
End Sub
If you know the VCS or vertical datum you want to work with, use ISpatialReferenceFactory3.CreateVerticalCoordinateSystem or ISpatialReferenceFactory3.CreateVerticalDatum, then pass in the appropriate factory code. See the following code example:
[C#] private void CreateVerticalReferenceSystem()
{
// 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 srFact3=obj as ISpatialReferenceFactory3;
// Dimension a vertical datum and VCS.
// Use the enumerations to create instances of the predefined objects.
IVerticalDatum verticalDatum=srFact3.CreateVerticalDatum((int)
esriSRVerticalDatumType.esriSRVertDatum_Alicante);
IVerticalCoordinateSystem verticalCoordinateSystem =
srFact3.CreateVerticalCoordinateSystem((int)
esriSRVerticalCSType.esriSRVertCS_Alicante);
}
[VB.NET] Private Sub CreateVerticalReferenceSystem()
' 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 srFact3 As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3=obj
' Dimension a vertical datum and VCS.
' Use the enumerations to create instances of the predefined objects.
Dim verticalDatum As IVerticalDatum=srFact3.CreateVerticalDatum(esriSRVerticalDatumType.esriSRVertDatum_Alicante)
Dim verticalCoordinateSystem As IVerticalCoordinateSystem=srFact3.CreateVerticalCoordinateSystem(esriSRVerticalCSType.esriSRVertCS_Alicante)
End Sub
See Also:
Creating a custom vertical coordinate systemTo 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 |