0

I've been trying to run some code in Python with ArcPy library.

Everything is working fine, but in the end of the code there is a part that I want to calculate the centroids, x and y, with CalculateGeometryAttributes_management(), like when we calculate field through ArcMap directly from attribute table, but it returns some error saying that the "module" object has no attribute "CalculateGeometryAttributes_management". I've searched around and found that maybe the only version of ArcGIS that supports this tool on ArcPy is ArcGIS 10.6, and which I have here is ArcGIS 10.5.

Is there any other way to calculate the centroids?

Here is the part of my code containing the calling to the tool (Everything else is working - already tested):

arcpy.AddField_management(net_clip, 'LAT', 'DOUBLE')
arcpy.AddField_management(net_clip, 'LON', 'DOUBLE')

arcpy.CalculateGeometryAttributes_management(net_clip,
                                             [["LAT", "CENTROID_Y"],
                                              ["LON", "CENTROID_X"]])

And here is the error message I get:

Traceback (most recent call last):
  File "D:/ArcPy_Classes/Scripts/sampling_sig.py", line 90, in <module>
    arcpy.CalculateGeometryAttributes_management(net_clip,
AttributeError: 'module' object has no attribute 'CalculateGeometryAttributes_management'
1
  • 1
    The information is available from the Polygon object returned in a DA UpdateCursor. It would be five lines of ArcPy to populate two columns from a third, and less than 20 lines to implement your own CalculateGeometryAttributes function.
    – Vince
    Jun 26, 2020 at 15:35

1 Answer 1

3

The module appears to have been released in the 10.6 version of ArcGIS. Only 10.6 is select-able.

If you have access to ArcGIS Pro you can also use a similar module: arcpy.CalculateGeometryAttributes

I'm sorry this isn't the answer you were hoping for.

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.