Gets the name of the unit.
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)
}
LinearUnit - Create a LinearUnit with a factory code
try
{
// create a british 1936 foot
var britFoot = LinearUnit.CreateLinearUnit(9095);
string unitName = britFoot.Name; // "Foot_British_1936"
double conversionFactor = britFoot.ConversionFactor; // 0.3048007491
double metersPerUnit = britFoot.MetersPerUnit;
int factoryCode = britFoot.FactoryCode; // 9095
// convert 10 british 1936 feet to centimeters
double val = britFoot.ConvertTo(10, LinearUnit.Centimeters);
// convert 10 m to british 1936 feet
val = britFoot.ConvertFromMeters(10);
}
catch (ArgumentException)
{
// ArgumentException will be thrown by CreateLinearUnit
// in the following scenarios:
// - if the factory code used is a non-linear 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)
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.