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'
Polygon
object returned in a DAUpdateCursor
. It would be five lines of ArcPy to populate two columns from a third, and less than 20 lines to implement your ownCalculateGeometryAttributes
function.