ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / Polygon Class / Area Property
Example

In This Topic
    Area Property (Polygon)
    In This Topic
    Gets the area of this instance.
    Syntax
    public override double Area {get;}
    Public Overrides NotOverridable ReadOnly Property Area As Double
    Example
    Build a donut polygon
    {
      List<Coordinate2D> outerCoordinates = new List<Coordinate2D>();
      outerCoordinates.Add(new Coordinate2D(10.0, 10.0));
      outerCoordinates.Add(new Coordinate2D(10.0, 20.0));
      outerCoordinates.Add(new Coordinate2D(20.0, 20.0));
      outerCoordinates.Add(new Coordinate2D(20.0, 10.0));
    
      // define the inner polygon as anti-clockwise
      List<Coordinate2D> innerCoordinates = new List<Coordinate2D>();
      innerCoordinates.Add(new Coordinate2D(13.0, 13.0));
      innerCoordinates.Add(new Coordinate2D(17.0, 13.0));
      innerCoordinates.Add(new Coordinate2D(17.0, 17.0));
      innerCoordinates.Add(new Coordinate2D(13.0, 17.0));
    
      PolygonBuilderEx pbEx = new PolygonBuilderEx(outerCoordinates);
      Polygon donutEx = pbEx.ToGeometry() as Polygon;
      double areaEx = donutEx.Area;       // area = 100
    
      pbEx.AddPart(innerCoordinates);
      donutEx = pbEx.ToGeometry() as Polygon;
    
      areaEx = donutEx.Area;    // area = 84.0
    
      areaEx = GeometryEngine.Instance.Area(donutEx);    // area = 84.0
    }
    Get the outermost rings of a polygon
    {
      List<Polygon> internalRings = new List<Polygon>();
    
      // explode the parts of the polygon into a list of individual geometries
      // see the "Get the individual parts of a multipart feature"
      // snippet for MultipartToSinglePart
      var parts = MultipartToSinglePart(polygon); //any polygon
    
      // get an enumeration of clockwise geometries (area > 0) ordered by the area
      var clockwiseParts = parts.Where(geom => ((Polygon)geom).Area > 0)
                            .OrderByDescending(geom => ((Polygon)geom).Area);
    
      // for each of the exterior rings
      foreach (var part in clockwiseParts)
      {
        // add the first (the largest) ring into the internal collection
        if (internalRings.Count == 0)
        {
          internalRings.Add(part as Polygon);
        }
    
        // use flag to indicate if current part is within the already selection polygons
        bool isWithin = false;
    
        foreach (var item in internalRings)
        {
          if (GeometryEngine.Instance.Within(part, item))
          {
            isWithin = true;
          }
        }
    
        // if the current polygon is not within any polygon of the internal collection
        // then it is disjoint and needs to be added to
        if (isWithin == false)
        {
          internalRings.Add(part as Polygon);
        }
      }
    
      PolygonBuilderEx outerRings = new PolygonBuilderEx();
      // now assemble a new polygon geometry based on the internal polygon collection
      foreach (var ring in internalRings)
      {
        outerRings.AddParts(ring.Parts);
      }
    
      // the final geometry of the outer rings
      var outerRingsResult = outerRings.ToGeometry();
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also