This is a pretty general question. I just wondering what tips and tricks GIS programmers have used to speed up arcpy scripts that you import into the toolbox and run.
I work most everyday writing little scripts to help non-GIS users at my office process GIS data. I have found that ArcGIS 10.0 processing in general is slower than 9.3.1 and sometimes it gets even slower when running a python script.
I'm going to list a particular example of a script that takes over 24 hours to run. It's a loop that tabulates the area of a raster in a buffer for each shape in the buffer. The buffer has about 7000 shapes. I don't believe it should run this long. A
while x <= layerRecords: arcpy.SetProgressorLabel("Tabulating Row: " + str(x) + " of " + str(ELClayerRecords)) arcpy.SelectLayerByAttribute_management(Buff,"NEW_SELECTION", "Recno = " + str(x)) # Selecting the record TabulateArea(Buff, "Recno", MatGRID, "VALUE", ScratchWS + "/tab" + str(z) +".dbf", nMatGRIDc) # Tabulate the area of the single row arcpy.AddMessage (" - Row: " + str(x) + " completed") x = x + 1 z = z + 1
Before anyone says it, I have run tabulate area on the entire buffer, but it produces errors if run on more then 1 record. It's a flawed tool, but I have to use it.
Anyways, if anyone has any ideas on how to optimize, or speed up this script, it would be most appreciated. Otherwise, if you have any speed up tricks for python, when used in ArcGIS, I'd love to hear them.
Thanks in advance for any replies!