ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Geometry Namespace / AreaUnit Class / CreateAreaUnit Method / CreateAreaUnit(Int32) Method
The area unit factory code
Example

In This Topic
    CreateAreaUnit(Int32) Method
    In This Topic
    Convenience method to quickly create a AreaUnit instance.
    Syntax
    public static AreaUnit CreateAreaUnit( 
       int factoryCode
    )
    Public Overloads Shared Function CreateAreaUnit( _
       ByVal factoryCode As Integer _
    ) As AreaUnit

    Parameters

    factoryCode
    The area unit factory code

    Return Value

    Exceptions
    ExceptionDescription
    The factoryCode is not a valid area unit code
    Remarks

    The available area units of measure.

    Factory Code Unit Name
    109401 Square hectare
    109403 US acre
    109404 Square meter
    109405 Square foot
    109414 Square kilometer
    109439 Square mile
    109442 Square yard
    109450 Square decimeter
    109451 Square centimeter
    109452 Square millimeter
    109453 Square inch
    109463 Square ares

    Example
    AreaUnit - Create an AreaUnit
    try
    {
      var myFactoryCodeInit = AreaUnit.CreateAreaUnit(109439);     // 109439 is the factory code for square miles
    
      var myWktUnit = AreaUnit.CreateAreaUnit("HECTARE_AREAUNIT[\"H\",10000.0]");
    
      var myCustomUnit = AreaUnit.CreateAreaUnit("myAreaUnit", 12);
    }
    catch (ArgumentException)
    {
      // ArgumentException will be thrown by CreateAreaUnit in the following scenarios
      // - if the factory code used is a non-areal factory code  (i.e. it corresponds to degrees which is an angular unit code)
      // - if the factory code used is invalid (i.e. it is negative or doesn't correspond to any factory code)
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also