Provides access to members that return properties common to rings and polygons.
Description
Use the IAreainterface to get the Area of a Geometry. It can also be used to get the Centroid point and Label****point for a Geometry.
Members
Name | Description | |
---|---|---|
Area | The area. | |
Centroid | The center of gravity (centroid). | |
LabelPoint | A point guaranteed to be inside this area. | |
QueryCentroid | Copies the centroid of this area to the specified point. | |
QueryLabelPoint | Copies to the input point a point guaranteed to be inside this area. |
IArea.Area Property
The area.
Public ReadOnly Property Area As Double
public double Area {get;}
Description
Returns the area enclosed between the Exterior Rings and the Interior Rings of the 2 (or 2.5) Dimensional geometry. Interior Rings return a negative Area.
Remarks
IArea.Centroid Property
The center of gravity (centroid).
Public ReadOnly Property Centroid As IPoint
public IPoint Centroid {get;}
Description
Returns the Centroid of the 2 (or 2.5) Dimensional figure. The Centroid is the center of the weighted area.
Remarks
The Centroid does not always occur inside the Area of the geometry. The Centroid is not the same as the center of the geometry or the Envelope binding the geometry (but it may be if and only if that is also the center of the weighted area).
IArea.LabelPoint Property
A point guaranteed to be inside this area.
Public ReadOnly Property LabelPoint As IPoint
public IPoint LabelPoint {get;}
Description
Returns the Label Point of the object. The Label Point is the point at which the label is located. The Label Point is always located within the Area of the object.
IArea.QueryCentroid Method
Copies the centroid of this area to the specified point.
Public Sub QueryCentroid ( _
ByVal Center As IPoint _
)
public void QueryCentroid (
IPoint Center
);
Description
Queries the Centroid of the 2 (or 2.5) Dimensional figure. The Centroid is the center of the weighted area. You must instantiate the Point before calling QueryCentroid. For example,
Dim pPoint as IPoint
Set pPoint = New Point
Remarks
The Centroid does not always occur inside the Area of the geometry. The Centroid is not the same as the center of the geometry or the Envelope binding the geometry (but it may be if and only if that is also the center of the weighted area).
Note: The output geometry must be co-created prior to the query. The output geometry is not co-created by the method; it is populated. This can be used in performance critical situations. For example, creating the geometry only once outside a loop and use the query method could improve performance.
IArea.QueryLabelPoint Method
Copies to the input point a point guaranteed to be inside this area.
Public Sub QueryLabelPoint ( _
ByVal LabelPoint As IPoint _
)
public void QueryLabelPoint (
IPoint LabelPoint
);
Description
Queries the Label Point of the object. The Label Point is the point at which the label is located. The Label Point is always located within the Area of the object. You must instantiate the point before calling QueryLabelPoint. For example,
Dim pPoint as IPoint
Set pPoint = New Point
Remarks
Note: The output geometry must be co-created prior to the query. The output geometry is not co-created by the method; it is populated. This can be used in performance critical situations. For example, creating the geometry only once outside a loop and use the query method could improve performance.
Classes that implement IArea
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. |
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. |
// 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();
}
}
' 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