Frequently asked question

Why are the Length and Area fields returning zero?

Last Published: April 25, 2020

Answer

Some storage types, such as Oracle Spatial (SDO_GEOMETRY), do not maintain an Area or Length field. This is noted in the ArcGIS Online Developer help. When queried, such as using identify in ArcMap, these fields return zero and not an error message.

If ArcObjects is being used it is necessary to detect a response of zero for Area and Length and then use the following:
Length: IPolyline.Length, IPolygon.Length
Area: IArea.Area

By using these, the length and area are calculated based on the shape object.

Code:

... Setup pFeature as IFeature ...
... Setup pFC as IFeatureClass for esriGeometryPolygon ...
Dim strShapeFieldName As String
Dim strLengthFieldName As String
Dim strAreaFieldName As String


strShapeFieldName = pFC.ShapeFieldName
strAreaFieldName = pFC.AreaField.Name
strLengthFieldName = pFC.LengthField.Name

Dim pArea As IArea
Dim pPolygon As IPolygon
Set pArea = pFeature.Shape
Set pPolygon = pFeature.Shape

MsgBox "These may be zero: " & vbNewLine _
& " Area: " & pFeature.Value(pFeature.Fields.FindField(strAreaFieldName)) & vbNewLine _
& " Length: " & pFeature.Value(pFeature.Fields.FindField(strLengthFieldName))

MsgBox "These will never be zero: " & vbNewLine _
& " Area: " & pArea.Area & vbNewLine _
& " Length: " & pPolygon.length

Article ID:000009504

Software:
  • ArcMap
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic