I'm attempting run a calculate field for a feature layer that I'm creating in this tutorial. I can't seem to set it up to run though. ERROR 999999: Error executing function. Failed to execute (CalculateField)... I want the expression to run and populate the new field in the feature layer,fc.
try: # Import the mod import arcpy from arcpy import env
# Set up the environmentenv.workspace = r"E:\GISTutorial_for_PyScripting\GISTPython\Data\FireDepartment.gdb"env.overwriteOutput = True# Create a list of all the box zone feature classesfcBoxZones = arcpy.ListFeatureClasses("FireBoxMap*")# fcBoxZones = arcpy.ListFeatureClasses("FireBoxMap_14")# Start a for statment to iterate through the filesfor fc in fcBoxZones: # Get the first file - it's stored in fc print fc# Add field to hold the resultsarcpy.AddField_management (fc, "LaneMiles", "LONG")# Select the street lanesarcpy.MakeFeatureLayer_management(r"E:\GISTutorial_for_PyScripting\GISTPython\Data\City of Oleander.gdb\Street_Centerlines", "Lanes_lyr")# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script# The following inputs are layers or table views: "FireBoxMap", "Street Centerlines"arcpy.SelectLayerByLocation_management(in_layer="Lanes_lyr", overlap_type="INTERSECT", select_features=fc, search_distance="", selection_type="NEW_SELECTION", invert_spatial_relationship="NOT_INVERT")laneCount = int(arcpy.GetCount_management("Lanes_lyr").getOutput(0))print str(laneCount)#Update fieldarcpy.CalculateField_management(in_table=fc, field="LaneMiles", expression=" [Lanes] * [SHAPE_Length]", expression_type="VB", code_block="")print "updated LaneMiles field"except Exception as e: print(e)
أكثر...

try: # Import the mod import arcpy from arcpy import env
# Set up the environmentenv.workspace = r"E:\GISTutorial_for_PyScripting\GISTPython\Data\FireDepartment.gdb"env.overwriteOutput = True# Create a list of all the box zone feature classesfcBoxZones = arcpy.ListFeatureClasses("FireBoxMap*")# fcBoxZones = arcpy.ListFeatureClasses("FireBoxMap_14")# Start a for statment to iterate through the filesfor fc in fcBoxZones: # Get the first file - it's stored in fc print fc# Add field to hold the resultsarcpy.AddField_management (fc, "LaneMiles", "LONG")# Select the street lanesarcpy.MakeFeatureLayer_management(r"E:\GISTutorial_for_PyScripting\GISTPython\Data\City of Oleander.gdb\Street_Centerlines", "Lanes_lyr")# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script# The following inputs are layers or table views: "FireBoxMap", "Street Centerlines"arcpy.SelectLayerByLocation_management(in_layer="Lanes_lyr", overlap_type="INTERSECT", select_features=fc, search_distance="", selection_type="NEW_SELECTION", invert_spatial_relationship="NOT_INVERT")laneCount = int(arcpy.GetCount_management("Lanes_lyr").getOutput(0))print str(laneCount)#Update fieldarcpy.CalculateField_management(in_table=fc, field="LaneMiles", expression=" [Lanes] * [SHAPE_Length]", expression_type="VB", code_block="")print "updated LaneMiles field"except Exception as e: print(e)
أكثر...