calculate_area_for_selection on unit tests after 2.9.0 upgrade

798
2
11-29-2021 09:00 AM
IanAlexander
New Contributor II

After upgrading to ArcGIS Pro 2.9.0 , my unit tests running arcpy.management.CalculateGeometryAttributes

have been failing with the error below.

The code works inside the ArcGIS Pro application without issue, but fails when run from the command line.

 

Traceback (most recent call last):

File "C:\Users\Jenkins_SA\Documents\Jenkins_Home\Hal\LRG_HAL_Tools\mapper\Edit_Layer.py", line 301, in calculate_area_for_selection

"SAME_AS_INPUT")

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4153, in CalculateGeometryAttributes

raise e

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4150, in CalculateGeometryAttributes

retval = convertArcObjectToPythonObject(gp.CalculateGeometryAttributes_management(*gp_fixargs((in_features, geometry_property, length_unit, area_unit, coordinate_system, coordinate_format), True)))

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>

return lambda *args: val(*gp_fixargs(args, True))

arcgisscripting.ExecuteError: Traceback (most recent call last):

File "c:\program files\arcgis\pro\Resources\ArcToolbox\scripts\calculategeometry.py", line 276, in <module>

CalculateGeometry(fc, properties, lUnit, aUnit, cs, cformat)

File "c:\program files\arcgis\pro\Resources\ArcToolbox\scripts\calculategeometry.py", line 125, in CalculateGeometry

ucur.updateRow(row)

RuntimeError: An edit operation is required.

 

 

Command That Leads To Error:

The call:
    arcpy.management.CalculateGeometryAttributes(self.the_layer, "acres AREA", '', "ACRES",
'PROJCS["NAD_1983_StatePlane_New_Mexico_Central_FIPS_3002_Feet",'
'GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",'
'SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM['
'"Greenwich",0.0],UNIT["Degree",0.0174532925199433]],'
'PROJECTION["Transverse_Mercator"],PARAMETER['
'"False_Easting",1640416.666666667],PARAMETER['
'"False_Northing",0.0],PARAMETER["Central_Meridian",'
'-106.25],PARAMETER["Scale_Factor",0.9999],PARAMETER['
'"Latitude_Of_Origin",31.0],UNIT["Foot_US",'
'0.3048006096012192]]',
"SAME_AS_INPUT")

 

 

0 Kudos
2 Replies
IanAlexander
New Contributor II

Thank you for the response.  Unfortunately, I cannot add a column to the layer.  It would be nice if Add Geometry Attributes had a parameter for the column.

I looked into CalculateField_management with an Arcade expression, which works, but the spatial reference seems to be limited to a wkid , which returns different results than the more specific spacial reference I am using in the original command.

The issue is new, as it did not occur prior to 2.9.0 . I will submit a ticket.

 

0 Kudos