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

In This Topic
    ConvertTo(Double,LinearUnit) Method
    In This Topic
    Converts a value in the unit of this instance to the provided linear unit.
    Syntax
    public double ConvertTo( 
       double inDistance,
       LinearUnit outUnit
    )
    Public Function ConvertTo( _
       ByVal inDistance As Double, _
       ByVal outUnit As LinearUnit _
    ) As Double

    Parameters

    inDistance
    Distance in the units of this instance.
    outUnit
    Unit to convert to.

    Return Value

    Distance converted to the specified unit.
    Exceptions
    ExceptionDescription
    The outUnit is null.
    Example
    LinearUnit - Convert between centimeters and millimeters
    // convert 11 centimeters to millimeters
    double mm = LinearUnit.Centimeters.ConvertTo(11, LinearUnit.Millimeters);
    
    // convert the result back to centimeters
    double cm = LinearUnit.Millimeters.ConvertTo(mm, LinearUnit.Centimeters);
    
    // convert the millimeter result back to meters
    double meters = LinearUnit.Millimeters.ConvertToMeters(mm);
    
    LinearUnit - Create a Custom LinearUnit
    // create a custom linear unit - there are 0.33 meters per myLinearUnit
    var myLinearUnit = LinearUnit.CreateLinearUnit("myCustomLinearUnit", 0.33);
    string name = myLinearUnit.Name;                          // myCustomLinearUnit
    double convFactor = myLinearUnit.ConversionFactor;        // 0.33
    int code = myLinearUnit.FactoryCode;                      // 0 for custom units
    double metersUnit = myLinearUnit.MetersPerUnit;           // 0.33
    string toString = myLinearUnit.ToString();                // same as Name - myCustomLinearUnit
    
    // convert 10 centimeters to myLinearUnit 
    double convertedVal = LinearUnit.Centimeters.ConvertTo(10, myLinearUnit);
    
    
    // get the wkt
    string lu_wkt = myLinearUnit.Wkt;
    
    // create an angular unit from this wkt
    var anotherLinearUnit = LinearUnit.CreateLinearUnit(lu_wkt);
    // anotherLinearUnit.ConversionFactor = 0.33
    // anotherLinearUnit.FactoryCode = 0    
    // anotherLinearUnit.MetersPerUnit = 0.33
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also