laptop and a wrench

Bug

Using Python as an option with the 'Calculate Field' tool to calculate geometry generates an incorrect field value of '-1' if values in the expression are integers.

Last Published: August 25, 2014 ArcGIS for Desktop
Bug ID Number NIM059935
SubmittedAugust 11, 2010
Last ModifiedJune 5, 2024
Applies toArcGIS for Desktop
Version found9.3.1
Operating SystemWindows OS
Operating System Version2008 64 Bit
StatusNon-Reproducible

Additional Information

No Public Explanation

Workaround

Either cast as a float "float(!shape.area!), or use VB code like so:Dim pMxDoc As IMxDocumentDim pGeometry As IGeometryDim pMap As IMapDim pArea As IAreaDim dArea As DoubleDim dC As DoubleDim sOutMeasure As StringDim bSrefFromMap As Boolean'======================='Adjust the parameters below'bSrefFromMap = True ==> the area will be calculated in the projection of the Map'bSrefFromMap = False ==> the area will be calculated in the projection of the databSrefFromMap = False'unmark the desired output units'sOutMeasure = "Acres"'sOutMeasure = "Square Kilometers"sOutMeasure = "Square Meters"'sOutMeasure = "Square Miles"'=======================If (IsNull([Shape])) Then dArea = -1Else Set pGeometry = [Shape] If (pGeometry.IsEmpty) Then dArea = -1 Else If (bSrefFromMap) Then Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap pGeometry.Project pMap.SpatialReference Select Case pMap.MapUnits Case 3 'Feet Select Case sOutMeasure Case "Acres" dC = 0.00002295684 Case "Square Kilometers" dC = 0.0000000930787 Case "Square Meters" dC = 0.092903 Case "Square Miles" dC = 0.0000000359375 Case Else dC = 1 End Select Case 9 'Meters Select Case sOutMeasure Case "Acres" dC = 0.0002471 Case "Square Kilometers" dC = 0.000001 Case "Square Meters" dC = 1 Case "Square Miles" dC = 0.0000003861022 Case Else dC = 1 End Select Case Else dC = 1 End Select Else dC = 1 End If Set pArea = pGeometry dArea = pArea.Area * dC End IfEnd If

Steps to Reproduce

Bug ID: NIM059935

Software:

  • ArcGIS for Desktop

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options