arcpy.AddIndex_management error

المشرف العام

Administrator
طاقم الإدارة
I am trying to optimize a script that uses 'addJoin_management'. To do this efficiently, i am attempting to add an attribute index on the join table. I am getting a generic error when i do this though.

arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Failed to execute (AddIndex).

However, in ArcMap I have created a feature class and added the index and performed the join without any issues. Do In_Memory variables have issues with attribute indexes? I am not sure why i can not create an attribute index on one, or see any indexes listed when I do a arcpy.ListIndexes().

Here is my code, it basically does an intersect, dissolve, calculate acres, join and then re-calculate the acres column to the target table.

print("\n*Processing " + f['new_col_name'] + ' acres/pct*') inFeature = os.path.join(base_path, f['feature']) #the feature class being ran in this loop # create in_memory variables feature = "in_memory" + "\\" + "mem_feature" intersected = "in_memory" + "\\" + "mem_intersected" #results of intersecting dissolved = "in_memory" + "\\" + "mem_dissolved" #for making a feature class dis_layer = "in_memory" + "\\" + "mem_dis_layer" #for making a layer from dissolved table_view = "in_memory" + "\\" + "mem_table_view" #make a table view for addJoin arcpy.MakeFeatureLayer_management(inFeature, feature, f['def_query']) print('Intersecting...') arcpy.Intersect_analysis([feature, parcels], intersected, "ALL") print('Dissolving...') arcpy.Dissolve_management(intersected, dissolved, ["FID_Parcels_2013", "CALC_ACRE"]) #carry over parcels acre field 'CALC_ACRE'. This field may change. print('Calculating Acres...') arcpy.CalculateField_management(dissolved, "CALC_ACRE", "!shape.area@acres!", "PYTHON_9.3") print('Joining Table...') print('\nIndexes:') indexes = arcpy.ListIndexes(dissolved) for index in indexes: print(index) #no indexs are seen here?? arcpy.AddIndex_management(dissolved,"FID_Parcels_2013", "ID", "UNIQUE", "ASCENDING") arcpy.MakeFeatureLayer_management(dissolved, dis_layer) arcpy.MakeTableView_management(table_path, table_view) arcpy.AddJoin_management(table_view, "OBJECTID", dis_layer, "FID_Parcels_2013") #calculate fields from joined table newfield = 'admin_attr.' + f['new_col_name'] print('calculating new acre field...') arcpy.CalculateField_management(table_view, newfield +'_acres', "!attr_dissolved.CALC_ACRE!", "PYTHON") print('calculating new pct field...') arcpy.CalculateField_management(table_view, newfield+'_pct', "format((!" + newfield +'_acres' + "! or 0)/!attr_dissolved.CALC_ACRE! * 100, '.3f')", "PYTHON") print('Cleaning up...') arcpy.Delete_management("in_memory") arcpy.RemoveJoin_management(table_view)

أكثر...
 
أعلى