3

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).

My code does an intersect, dissolve, calculate acres, join and then re-calculate the acres column to the target table.

EDIT: See below for my solution.

asked Dec 23, 2015 at 17:33
9
  • 1
    I have been doing something very similar recently in model builder and can confirm that in_memory datasets do not support indices. I ended up using the %ScratchGDB% workspace in model builder Commented Dec 23, 2015 at 17:35
  • 1
    It's strange, I had the same problem where I needed to add an index to both layers I am joining, it is only one of them that fail though with an error along the lines of 'index exists'. While the other runs every time. Also, I write the line differently, in your case arcpy.AddIndex_management(dissolved,"FID_Parcels_2013", "ID", 1, 1) rather than spelling out the 'unique' and 'ascending' options. Does "ID" stands for your index name? I run my data off disk so like @Hornbydd said it might be an in memory issue Commented Dec 23, 2015 at 17:50
  • Yes ID is the index name. I want to avoid writing anything to disk but it looks like I may have to in order to perform the addIndex operation. Commented Dec 23, 2015 at 19:08
  • did you try the, the other code? with 1,1 rather than spelling out the options? because I'd think it would give more than a generic 9999 error, if it is not a syntax issue... Commented Dec 23, 2015 at 21:57
  • I didnt get a chance to try that out. Ill give it a shot when i return to work monday. For now i am just writing the 'dissolved' to disk and deleting after I have completed all the other steps. Commented Dec 24, 2015 at 0:36

1 Answer 1

2

My Solution: I was never able to get the in_memory variable working with AddIndex_management. I ended up using the arcpy.env.scratchGDB.

# in_memory variables do not work with AddIndex Management
# dissolve_out = "in_memory" + "\\" + "mem_dissolved" 
# The solution:
dissolve_out = os.path.join(arcpy.env.scratchGDB, "scratch_dissolve_out")
arcpy.AddIndex_management(dissolve_out ,"FID_Parcels_2013", "ID", "UNIQUE", "ASCENDING")
answered Dec 7, 2016 at 15:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.