ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / AngularUnit Class / ConvertTo(Double,AngularUnit) Method
Angle in the units of this instance.
Unit to convert to.
Example

In This Topic
    ConvertTo(Double,AngularUnit) Method
    In This Topic
    Converts the angle to the provided angular unit.
    Syntax
    public double ConvertTo( 
       double inAngle,
       AngularUnit outUnit
    )
    Public Function ConvertTo( _
       ByVal inAngle As Double, _
       ByVal outUnit As AngularUnit _
    ) As Double

    Parameters

    inAngle
    Angle in the units of this instance.
    outUnit
    Unit to convert to.

    Return Value

    Angle converted to the specified unit.
    Exceptions
    ExceptionDescription
    The outUnit is null.
    Example
    AngularUnit - Create an AngularUnit with a factory code
    try
    {
      // create a Grad unit
      var grad = AngularUnit.CreateAngularUnit(9105);
      string unitName = grad.Name;                        // Grad
      double conversionFactor = grad.ConversionFactor;    // 0.015708
      double radiansPerUnit = grad.RadiansPerUnit;
      int factoryCode = grad.FactoryCode;                 // 9105
    
      // convert 10 grads to degrees
      double val = grad.ConvertTo(10, AngularUnit.Degrees);
    
      // convert 10 radians to grads
      val = grad.ConvertFromRadians(10);
    }
    catch (ArgumentException)
    {
      // ArgumentException will be thrown by CreateAngularUnit in
      // the following scenarios:
      // - if the factory code used is a non-angular factory code
      //   (i.e. it corresponds to square meters which is an area unit code)
      // - if the factory code used is invalid
      //   (i.e. it is negative or doesn't correspond to any factory code)
    }
    
    AngularUnit - Create a Custom AngularUnit
    // custom unit - 3 radians per unit
    var myAngularUnit = AngularUnit.CreateAngularUnit("myCustomAngularUnit", 3);
    string Name = myAngularUnit.Name;                   // myCustomAngularUnit
    double Factor = myAngularUnit.ConversionFactor;     // 3
    int Code = myAngularUnit.FactoryCode;               // 0 because it is a custom angular unit
    double radiansUnit = myAngularUnit.RadiansPerUnit;  // 3
    
    // convert 10 degrees to my unit
    double converted = AngularUnit.Degrees.ConvertTo(10, myAngularUnit);
    // convert it back to degrees
    converted = myAngularUnit.ConvertTo(converted, AngularUnit.Degrees);
    
    // convert 1 radian into my angular units
    converted = myAngularUnit.ConvertFromRadians(1);
    
    // get the wkt
    string wkt = myAngularUnit.Wkt;
    
    // create an angular unit from this wkt
    var anotherAngularUnit = AngularUnit.CreateAngularUnit(wkt);
    // anotherAngularUnit.ConversionFactor = 3
    // anotherAngularUnit.FactoryCode = 0    
    // anotherAngularUnit.RadiansPerUnit = 3
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also