Could not save raster dataset to ("path") with output format FGDBR.

3086
3
Jump to solution
03-18-2014 05:15 PM
BenSciance
New Contributor II
I'm running a loop that iterates through a series of map algebra expressions and I get this error:

Traceback (most recent call last):   File "G:\Thesis\BACKUP\Thesis\Code\PyCode\LandSatAccurAssesment\OneD_Analysis_Code_USE.py", line 62, in <module>     outsetnull=SetNull (outrast,outrast, "Value < 0")   File "C:\Program Files\ArcGIS\Desktop10.1\arcpy\arcpy\sa\Functions.py", line 311, in SetNull     where_clause)   File "C:\Program Files\ArcGIS\Desktop10.1\arcpy\arcpy\sa\Utils.py", line 47, in swapper     result = wrapper(*args, **kwargs)   File "C:\Program Files\ArcGIS\Desktop10.1\arcpy\arcpy\sa\Functions.py", line 306, in wrapper     where_clause)   File "C:\Program Files\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>     return lambda *args: val(*gp_fixargs(args, True)) RuntimeError: ERROR 010240: Could not save raster dataset to C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\W_Gauges\km.gdb\minus_ras2 with output format FGDBR.


I've troubleshooted by reading through other forum posts about this error and still have not debugged my code:

import arcpy from arcpy import env from arcpy.sa import*  env.workspace =r"C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\W_Gauges\km.gdb"  OneD_savepath="C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\W_Gauges\OneD.gdb"  env.overwriteOutput = True  arcpy.overwriteOutput = True  # List inputs print 'listing inputs' dem="C:\Users\mbs7038\Documents\New_Landsat_Imagery\For_Area_Calc\Gauges_For_AccuracyAssessment\W_Gauges\W_Gauges.gdb\W_Basin_DEM"  print 'listing rasters' kriglist= arcpy.ListRasters("a*")   # Check out the ArcGIS Spatial Analyst extension license print 'checking spatial analyst license' arcpy.CheckOutExtension("Spatial")   # Starting from the first krig raster, iterate through to the fourth [0] - [3] # start at index [0] print 'initializing for loop' for k in range (3):     print(k)     print "1 Dimensional Analysis Part 1:"     print "calculating difference"     outrast = ((Raster(kriglist) - dem))      print "1 Dimensional Analysis Part 2:"     print "running setnull"     outsetnull=SetNull (outrast,outrast, "Value < 0")     outrastName = "oneD" + "_" + (kriglist)[:-10]      print 'saving 1D grid'     outsetnull.save(OneD_savepath + "/" + outrastName)       print arcpy.GetMessages()


When the env.workspace path is set to other folders containing multiple rasters, sometimes the code works fine while other times it will iterate though the first few rasters like its supposed to, and then I get the error message (010240): could not save raster with output format FGDBR.  In this instance, the line of code stops working during the Setnull function.  Its looks like the code attempts to save a raster grid using default naming parameters, "minus_ras2", to my env.workspace.  Is there a way to get it to not do this?

Any suggestions?

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor
Just an idea, do not know if it will help but have you tried setting the ScratchWorkspace environment?

Also your outrast is temporary but try actually saving it before you attempt to use it with the SetNull tool. I remember having some problem in Python and the way I solved it was to save the intermediate rasters.

Duncan

View solution in original post

0 Kudos
3 Replies
DuncanHornby
MVP Notable Contributor
Just an idea, do not know if it will help but have you tried setting the ScratchWorkspace environment?

Also your outrast is temporary but try actually saving it before you attempt to use it with the SetNull tool. I remember having some problem in Python and the way I solved it was to save the intermediate rasters.

Duncan
0 Kudos
BenSciance
New Contributor II
when you saved the intermediate rasters, did you call them in the next function?


.save(intermediate_file)

outextractbymask=(intermediate_file,mask)

0 Kudos
DuncanHornby
MVP Notable Contributor
Ben,

Yes I would call the function to create the raster (e.g. SetNull) then save them, then use them in the next function.
0 Kudos