AnsweredAssumed Answered

Intermittent error on CostDistance_sa loop-calculations

Question asked by billydekid on Mar 31, 2013
Latest reply on Apr 1, 2013 by billydekid
Hi All,

I'm newbie in python geoprocessing.
I created CostPath calculation permutations.
The problem is it runs sometimes and errors on different "set" of permutations.
It's an intermittent issues.. simillar like on this unanswered thread here [0].

Below are the codes:

# Import modules import arcpy,os,time,itertools  ############################################ #        USER DEFINED VARIABLES            #  ############################################ # Unique ID, can not contains invalid chars uniqueID = "Sumatera"  # Points points = ['BandaAceh', 'Jambi', 'Bengkulu']  # References dir of cost surface - as cost surface input dir (#2) cost_surface = "C:/Projects/CNG/CostSurface/costsurface" # Sumatera  # Environment workspace and set as input dir (#1) arcpy.env.workspace = "C:/Projects/CNG/Source"  # Ouput dirs baseOutput = "C:/Projects/CNG/Output-" + uniqueID + "/"  ############################################ #       DO NOT EDIT BELOW THIS LINE        # ############################################  # Final output dissolved/merged shapefiles OSHP = baseOutput + uniqueID + ".shp"  # Check out any necessary licenses arcpy.CheckOutExtension("spatial")  # Allow overwritten of output arcpy.env.overwriteOutput = True  # Calculate number of posibly permutations  lengthCombinations = len(list(itertools.permutations(points, 2))) i = 0  # Create output dirs if not os.path.exists(baseOutput):     os.makedirs(baseOutput)     print "Creating folders Spatial ouput: " + baseOutput + "\n"                  # Temp files / scratch workspace -- default settings #CostDis_shp9 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostDis_shp9" #COSTBACKLINK = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/COSTBACKLINK" #CostPat_shp6 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostPat_shp6"  print "START geoprocessing...\n" print "------------"  # # Permutations of each points for comb in itertools.permutations(points, 2):     i += 1     print "Processing [" + str(i) + "/" + str(lengthCombinations) + "]: " + comb[0] + "-" + comb[1]           SPath = comb[0] + ".shp"     DPath = comb[1] + ".shp"     ShpPath = baseOutput + comb[0] + comb[1] + ".shp"     DissolvePath = baseOutput + comb[0] + comb[1] + "_dis.shp"          CostDis_shp9 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostDis_shp9_" + str(i)     COSTBACKLINK = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/COSTBACKLINK_" + str(i)          CostPat_shp6 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostPat_shp6_" + str(i)          # Process: Cost Distance     arcpy.gp.CostDistance_sa(SPath, cost_surface, CostDis_shp9, "", COSTBACKLINK)          # Process: Cost Path     costPath = arcpy.gp.CostPath_sa(DPath, CostDis_shp9, COSTBACKLINK, CostPat_shp6, "EACH_CELL", "FID")                print "End Processing: " + comb[0] + "-" + comb[1] + "."     print "------------"     #====================================     # END OF PERMUTATIONS LOOP     #====================================


And the errors happens, like as follows:

START geoprocessing...  ------------ Processing [1/6]: BandaAceh-Jambi End Processing: BandaAceh-Jambi. ------------ Processing [2/6]: BandaAceh-Bengkulu End Processing: BandaAceh-Bengkulu. ------------ Processing [3/6]: Jambi-BandaAceh End Processing: Jambi-BandaAceh. ------------ Processing [4/6]: Jambi-Bengkulu End Processing: Jambi-Bengkulu. ------------ Processing [5/6]: Bengkulu-BandaAceh Cost Distance mapping Failed Traceback (most recent call last):   File "C:\Projects\CNG\permBestRoute_CNG_JawaSumatera2.py", line 113, in <module>     arcpy.gp.CostDistance_sa(SPath, cost_surface, CostDis_shp9, "", COSTBACKLINK)   File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 484, in <lambda>     return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Workspace or data source is read only. Workspace or data source is read only. The operation was attempted on an empty geometry. ERROR 010029: Unable to create the raster C:\Users\Billydekid\Documents\ArcGIS\Default.gdb\CostDis_shp9_5. Cost Distance mapping Failed ERROR 010067: Error in executing grid expression. Failed to execute (CostDistance).


In my code above, I try to create each raster database on each permutations rather than only single table to prevent locking issues.

Or..

The error "Workspace or data source is read only." is related to my arcpy.env.workspace issue?

Anyone have ideas or hints for this problem?

Thanks in advance.

[bayu]

[0] http://forums.arcgis.com/threads/78314-ERROR-quot-The-table-was-not-found.-VAT_CostDis_src_1-quot

Outcomes