AnsweredAssumed Answered

RuntimeError: ERROR 999999: Error executing function.

Question asked by ArqEric on Mar 10, 2016
Latest reply on Apr 7, 2016 by akk602dev

I'm trying to write in test field from some layer based on iterate feature selction. I get succes using model builder but I'm fail when I try with my own code.

The process with MB.

mb.jpg

The code and error.

mycode.jpg

Here is the code.

  1. import arcpy
  2. from arcpy import env
  3. env.workspace = r'D:\Eric\Ejercicio\shp\ejercicioTest.gdb\shp'
  4. crbuff = r'D:\Eric\Ejercicio\shp\ejercicioTest.gdb\shp\CRojaPBuff'
  5. insumo = r'D:\Eric\Ejercicio\shp\ejercicioTest.gdb\shp\Insumo'
  6. # Add field to insumo.
  7. arcpy.AddField_management(insumo, "test", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
  8. # Make a layer from crbuff to get the select by location works.
  9. arcpy.MakeFeatureLayer_management (crbuff, 'crbuff_layer')
  10. arcpy.MakeFeatureLayer_management (insumo, 'insumo_layer')
  11. # loop with cursor
  12. cursor = arcpy.SearchCursor(crbuff)
  13. field = "Lab" # Specify the field in the loop.
  14. for row in cursor:
  15.     print (row.getValue(field))
  16.     arcpy.SelectLayerByLocation_management('insumo_layer', "HAVE_THEIR_CENTER_IN", 'crbuff_layer', "", "NEW_SELECTION", "NOT_INVERT")
  17.     # Process: Calculate Field.
  18.     cursorIn = arcpy.UpdateCursor('insumo_layer')
  19.     for row in cursorIn:      
  20.         row.setValue("test", row.getValue(field))
  21.         cursorIn.updateRow(row)
  22.    
  23. # Process: Summary Statistics.
  24. intable = r'D:\Eric\Ejercicio\shp\Insumo.shp'
  25. outtable = r'D:\Eric\Ejercicio\shp'
  26. arcpy.Statistics_analysis(intable, outtable + "stats.dbf", "POB1 SUM;POB8 SUM;POB11 SUM;POB14 SUM;POB15 SUM;POB16 SUM;POB24 SUM;POB31 SUM;POB57 SUM;MIG7 SUM;INDI1 SUM;DISC1 SUM;DISC4 SUM;DISC5 SUM;DISC6 SUM;ECO1 SUM;ECO4 SUM;ECO25 SUM;ECO28 SUM;SALUD1 SUM;SALUD2 SUM;SALUD3 SUM;SALUD4 SUM;SALUD5 SUM;SALUD6 SUM", "test")

 

Thanks.

Outcomes