0

I am trying to calculate the area for my grid cells. For that, I give the following command

arcpy.CalculateGeometryAttributes_management(union, "AREA")

Here, union is my grid and I need to make a new field to store the area. I am getting the following error:

'module' object has no attribute 'CalculateGeometryAttributes_management'
  • 1
    What version of ArcGIS do you have? The arcpy.CalculateGeometryAttributes_management is only available in ArcGIS desktop 10.6 and Pro if you have 10.5 or earlier then the instruction isn't recognized, hence the error message saying 'arcpy doesn't have this attribute you've asked for'. – Michael Stimson Mar 13 at 7:40
  • 1
    It's Add Geometry Attributes you should be using, that came in at version 10.3. – Hornbydd Mar 13 at 8:55
  • Make sure you use the documentation associated with the version of ArcGIS you are using. If attempt to choose "Other versions" you'll see that 10.3-10.5 are greyed out, which indicates that this command was introduced at 10.6 – Vince Mar 13 at 10:42
2

Prior to ArcGIS 10.6 to add and calculate an area you add the field with arcpy.AddField_management, type of float or double then use arcpy.CalculateField_management with the geometry attributes. See examples here.

The workflow looks like this:

arcpy.AddField_management(Union,'AREA','DOUBLE')
arcpy.CalculateField_management(Union,'AREA','!shape.area!','PYTHON')

As near as I can tell the 10.6 CalculateGeometryAttributes is a shortcut to executing the two instructions required in previous versions.

  • Thanks it worked, but what are !shape.area! and PYTHON for? – lsr729 Mar 13 at 9:09
  • PYTHON says to use python syntax for the calculation statement, the fields are surrounded by exclamation marks - this is one of the few times that field delimiters are important. !shape! is the geometry of the row, the field is of type geometry resources.arcgis.com/en/help/main/10.2/index.html#//… which has a property area in the same units as the feature class coordinate system, it's a bit more complicated but not impossible to calculate the area in a different coordinate system if needed. – Michael Stimson Mar 13 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.