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


ISpatialReferenceFactory.CreateUnit Method (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (Geometry)  

ISpatialReferenceFactory.CreateUnit Method

Creates a predefined unit of measure.

[Visual Basic .NET]
Public Function CreateUnit ( _
    ByVal unitType As Integer _
) As IUnit
[C#]
public IUnit CreateUnit (
    int unitType
);
[C++]
HRESULT CreateUnit(
  long unitType,
  IUnit** Unit
);
[C++]

Parameters unitType unitType is a parameter of type long Unit [out, retval]
Unit is a parameter of type IUnit

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Use an element from the esriSRUnitType or esriSRUnit2Type enumerations as the unitType to create a particular predefined unit of measure.

[C#]

ISpatialReferenceFactory spatialReferenceFactory=new SpatialReferenceEnvironmentClass();
//Create the unit using the available units.  These can be
//found in the esriGeometry esriSRUnitType enumeration.
ILinearUnit linearUnit=spatialReferenceFactory.CreateUnit((int)esriSRUnitType.esriSRUnit_Foot) as ILinearUnit;

[Visual Basic .NET]

        Dim pSpatRefFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory
        'Set the spatial reference factory to a new spatial reference environment
        pSpatRefFact=New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment

        Dim pUnit As ESRI.ArcGIS.Geometry.ILinearUnit

        'Create the unit using the available units.  These can be
        'found in the esriGeometry esriSRUnitType enumeration.

        pUnit=pSpatRefFact.CreateUnit(ESRI.ArcGIS.Geometry.esriSRUnitType.esriSRUnit_Foot)

See Also

ISpatialReferenceFactory Interface | esriSRUnitType Constants | esriSRUnit2Type Constants

.NET Samples

Clonable object (Code Files: TestClass)

.NET Related Topics

Creating a custom geographic coordinate system | Creating a custom projected coordinate system | Creating a custom vertical coordinate system | Geometry