Hi yall,
I'm just starting to learn about python and notebooks and I'm attempting to use a series of arcpy tools to create a price calculation tool for some line layers. I won't go to far into the full details, but at the moment I'm having issue's with arcpy.management.CalculateField.
So we'll get to it. Here's my code (specifics removed to protect the innocent):
from arcgis.gis import GIS
gis = GIS("home")
from arcgis.features import FeatureLayer
import arcpy
#next cell
line_url = ("https://services8.arcgis.com/desired/line/layer/etc")
Line = FeatureLayer(line_url)
#next cell
arcpy.management.CalculateField(in_table=Line, field="$feature.Key", expression="$feature.Value1 + $feature.Value2", expression_type="ARCADE")[0]
And here is the error.
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [56], in <cell line: 9>()
----> 9 arcpy.management.CalculateField(in_table=Line, field="$feature.Key", expression="$feature.Value1 + $feature.Value2", expression_type="ARCADE")[0]
File /opt/conda/lib/python3.9/site-packages/arcpy/management.py:5788, in CalculateField(in_table, field, expression, expression_type, code_block, field_type, enforce_domains)
5786 return retval
5787 except Exception as e:
-> 5788 raise e
File /opt/conda/lib/python3.9/site-packages/arcpy/management.py:5785, in CalculateField(in_table, field, expression, expression_type, code_block, field_type, enforce_domains)
5783 from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
5784 try:
-> 5785 retval = convertArcObjectToPythonObject(gp.CalculateField_management(*gp_fixargs((in_table, field, expression, expression_type, code_block, field_type, enforce_domains), True)))
5786 return retval
5787 except Exception as e:
File /opt/conda/lib/python3.9/site-packages/arcpy/geoprocessing/_base.py:512, in Geoprocessor.__getattr__.<locals>.<lambda>(*args)
510 val = getattr(self._gp, attr)
511 if callable(val):
--> 512 return lambda *args: val(*gp_fixargs(args, True))
513 else:
514 return convertArcObjectToPythonObject(val)
RuntimeError: Object: Error in executing tool
I'm thinking that it's an issue with how I pull the layer into the notebook, but have no idea what is actually happening.
Thanks in advance for your help!