ArcObjects Library Reference (Geometry)  

IArea Interface

Provides access to members that return properties common to rings and polygons.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Use the IArea interface to get the Area of a Geometry. It can also be used to get the Centroid point and Label point for a Geometry.

Members

Description
Read-only property Area The area.
Read-only property Centroid The center of gravity (centroid).
Read-only property LabelPoint A point guaranteed to be inside this area.
Method QueryCentroid Copies the centroid of this area to the specified point.
Method QueryLabelPoint Copies to the input point a point guaranteed to be inside this area.

CoClasses that implement IArea

CoClasses and Classes Description
Envelope A rectangle with sides parallel to a coordinate system defining the extent of another geometry; optionally has min and max measure, height and ID attributes.
GeoEllipse (esriDefenseSolutions) Its a spheroidal ellipse.
GeoPolygon (esriDefenseSolutions) Its a spheroidal polygon.
MultiPatch A collection of surface patches.
Polygon A collection of rings ordered by their containment relationship; optionally has measure, height and ID attributes.
Ring An area bounded by one, closed sequence of connected segments; optionally has measure, height and ID attributes at each vertex.
[C#]
[C#]
// The example shows how to get the properties for a selected polygon in
// an ArcMap edit session.
public void showPolygonProperties()
{
    //get editor extension
    UID editorUID = new UIDClass();
    editorUID.Value = "esriEditor.Editor";
    IEditor editor = m_application.FindExtensionByCLSID(editorUID) as IEditor;
    if (editor.SelectionCount != 1)
    {
        System.Windows.Forms.MessageBox.Show("Start Editor and select one polygon");
        return;
    }
    IEnumFeature selectedFeatures = editor.EditSelection;
    IPoint centerPoint = new ESRI.ArcGIS.Geometry.Point();
    IPoint labelPoint = new ESRI.ArcGIS.Geometry.Point();
    IFeature feature = selectedFeatures.Next();
    while (feature != null)
    {
        if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
        {
            IArea area = feature.Shape as IArea;
            String message = "+++Polygon.IArea properties...\n" +
            "Area = " + area.Area + "\n" +
            "Center.X = " + area.Centroid.X + "\n" +
            "Center.Y = " + area.Centroid.Y + "\n" +
            "LabelPoint.X = " + area.LabelPoint.X + "\n" +
            "LabelPoint.Y = " + area.LabelPoint.Y;
            area.QueryCentroid(centerPoint);
            area.QueryLabelPoint(labelPoint);
            message = message + "\n" + "+++Polygon.IArea Queries..." + "\n" +
            "Center = " + centerPoint.X + "," + centerPoint.Y + "\n" +
            "Label = " + labelPoint.X + "," + labelPoint.Y;
            System.Windows.Forms.MessageBox.Show(message);
        }
        feature = selectedFeatures.Next();
    }
}
[Visual Basic .NET]

' The example shows how to get the properties for a selected polygon in
' an ArcMap edit session.

Public Sub t_IArea_polygon()
   Dim pID As New UID
   pID = "esriEditor.editor"
   Dim pEditor As IEditor
   Dim pApp As IApplication
   Set pApp = Application
   Set pEditor = pApp.FindExtensionByCLSID(pID)
  
   If pEditor.SelectionCount <>  1 Then
     MsgBox "select one polygon"
     Exit Sub
   End If
  
   Dim pEnumFeat As IEnumFeature
   Dim pFeature As IFeature
   Dim i As Long

   Set pEnumFeat = pEditor.EditSelection

   Dim pArea As IArea
   Dim pCenter As IPoint
   Dim pLabel As IPoint
   Set pCenter = New Point
   Set pLabel = New Point

   Set pFeature = pEnumFeat.Next

   While Not pFeature Is Nothing
     If pFeature.Shape.GeometryType = esriGeometryPolygon Then
       Set pArea = pFeature.Shape
       MsgBox "+++Polygon::IArea properties..." & vbCrLf _
       & "Area = " & pArea.Area & vbCrLf _
       & "Center.X = " & pArea.Centroid.X & vbCrLf _
       & "Center.Y = " & pArea.Centroid.Y & vbCrLf _
       & pArea.LabelPoint.X & vbCrLf _
       & "LabelPoint.Y = " & pArea.LabelPoint.Y

       pArea.QueryCentroid pCenter
       pArea.QueryLabelPoint pLabel
       MsgBox "+++Polygon::IArea Queries..." & vbCrLf _
       & "Center = " & pCenter.X & "," & pCenter.Y & vbCrLf _
       & "Label = " & pLabel.X & "," & pLabel.Y & vbCrLf

     End If
     Set pFeature = pEnumFeat.Next
   Wend

End Sub

.NET Samples

3D multipatch examples (Code Files: ExtrusionExamples) | Calculate area geoprocessing function tool (Code Files: CalculateAreaFunction) | Custom map selection commands (Code Files: SelectFeatures) | Custom subtyped command and tool (Code Files: PolyFeedbackTools) | Move a graphic along a path in ArcMap (Code Files: MapGraphicKeyframe) | Server spatial query COM utility (Code Files: VegUtils_VBNet) | Server spatial query server object extension (Code Files: Extension) | Tabbed feature inspector (Code Files: ObjectInspector TabbedInspector) |

.NET Related Topics

Geodatabase API best practices | How to develop the SOE | Server | Server object extensions (SOE) | Transforming envelopes in the display | Utility COM objects |