Error 010240 - Could not save raster dataset...

17091
20
02-27-2017 05:47 AM
NeilAyres
MVP Frequent Contributor

I am trying to do some raster processing in python.

As this will become a geoprocessing service eventually, I am using env.scratchGDB for storage.

There are several links to this error in Geonet & GIS SE, but I am still stumped.

I have also followed advice from Curtis Curtis Price to also set env.workspace = env.scratchGDB to save on copying time.

This bit works :

rasBase = "rasBase" + DateTimeStamp
rasBaseTmp = arcpy.sa.CreateConstantRaster(benchElev, "FLOAT", rasCellSize)
rasBaseTmp.save(rasBase)

But a few lines on I try to do a con on a difference raster...

rasAboveTmp = Con(arcpy.Raster(rasDiff) > 0, 1)
rasAbove = "rasAbove" + DateTimeStamp
rasAboveTmp.save(rasAbove)

Which gets me this mysterious error:

Traceback (most recent call last):
 File "C:\Data\Dev\Sprint4\Scripts\Tool_270217.py", line 222, in <module>
 rasAboveTmp.save(rasAbove)
RuntimeError: ERROR 010240: Could not save raster dataset to C:\Users\nayre\OneDrive\Documents\ArcGIS\scratch.gdb\rasAbove_270217_1524 with output format FGDBR.

Most of the posts refer to trying to save a grid format raster with a filename > 10(?) characters.

But this is a raster going into the scratch fgdb?

Anybody got an idea?

ArcGIS 10.4.1, Win10 64bit

20 Replies
ChrisSmith7
Frequent Contributor

So, it sounds like it's not a length issue since it's in a fgdb (and your first example works). It doesn't seem like a perms issue since you're specifying your scratch enviro (and your first example works), and, as you're appending a datestamp, it doesn't seem likely that you're trying to overwrite a file with same name.

 

I'm guessing you've already made sure you have space and aren't experiencing memory issues... Have you tried saving as a .tif or another directory just to see if anything changes? We might need to see more of the script, if you can give it, to see if there's something else at play.

0 Kudos
curtvprice
MVP Esteemed Contributor

Arcpy Map Algebra and Esri raster tools often save intermediate rasters to a folder (sometimes in grid format and sometimes [esp in more recent ArcGIS versions] in .tif format). This means that you really are better off sticking with grid-filename-safe temp names. My experience is that file based rasters perform better for processing than file GDB, so part of my advice of setting env.scratchWorkspace = env.workspace is to have that location be a filesystem folder workspace, not a gdb workspace.  Saving to file gdb is fine for a final raster is just fine, but when doing the processing I recommend sticking to using folder workspaces.

I really should write a book.

0 Kudos
NeilAyres
MVP Frequent Contributor

Thanks Curtis,

I'll do some more faffing the morning....

This tool has become a bit of a headache. One thing after another. Phew.

Thanks again for your advice.

Neil

0 Kudos
NeilAyres
MVP Frequent Contributor

Changed my worflow slightly, but still hitting the same brick wall.

I slice the elevation raster at a certain level, into above / below.

Then try and save each raster object to a polygon so i can get the area of each.

The tool fails at the RasterToPolygon step.

This message seems to indicate that the temporary raster object is trying to be saved into the default fgdb.

But no go, same as before.

RuntimeError: ERROR 010240: Could not save raster dataset to C:\Users\nayre\OneDrive\Documents\ArcGIS\Default.gdb\ifthe_ras with output format FGDBR.

Is this a bug or something?

0 Kudos
curtvprice
MVP Esteemed Contributor

This is weird. ifthe_ras is a temporary raster dataset. When you are doing arcpy map algebra often execution is delayed until it is needed (in this case, when you ran the raster to polygon tool).

What are the current settings of env.workspace and env.scratchWorkspace?

Just sayin, you could find the area using the ZonalGeometryAsTable too, but I think that would also generate the error.

0 Kudos
NeilAyres
MVP Frequent Contributor

Yes, tried doing a zonal geometry of the sliced raster.

Same result. I was imagining that the whole workflow would remain as "Raster Objects", rather than anything on disk (or where ever they go), but it appears that it has to save, before doing the next function. Which sort of negates the use of raster objects in the first place...

rasAboveArea = ZonalGeometry(rasAbove, "Value", "AREA")
 File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Functions.py", line 6240, in ZonalGeometry
 cell_size)
 File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Utils.py", line 53, in swapper
 result = wrapper(*args, **kwargs)
 File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\sa\Functions.py", line 6234, in Wrapper
 cell_size)
 File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda>
 return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: ERROR 010240: Could not save raster dataset to C:\Data\ESRI-SA\scratch\Default.gdb\ifthe_ras with output format FGDBR.
0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

numpy... just saying

0 Kudos
NeilAyres
MVP Frequent Contributor

Yes Dan,

was perusing your numpy pages to see how I would do this using np.array

0 Kudos
curtvprice
MVP Esteemed Contributor

The raster engine stacks up local operators as long as it can without saving intermediate rasters to disk. Any global or zonal operator (zonal statistics for example) requires that the output be saved to disk somewhere. The main advantage of the raster object scheme is not that everything happens in memory but that complex expressions can be built much easier with + / *  etc rather than the tools they call (Plus, etc). And, intermediate datasets get removed from disk for you when the arcpy session closes. 

Raster—ArcPy Classes | ArcGIS Desktop 

The hyphen in your pathname may be an issue. Raster processing in ArcGIS is especially sensitive to spaces or other non-alphanumerics (except _) in the path. The 010240 error points to a pathname issue. If you set the scratchWorkspace to a safer path, for example: C:\Data\scratch you may have better luck.

Earlier you saw the temp rasters written to your user Default.gdb. I have seen this behavior when the currently set scratchWorkspace does not exist.

Here's a method I use to make temp rasters are written to a folder:

from arcpy import env
from arcpy.sa import *
env.scratchWorkspace = env.scratchFolder
env.workspace = env.scratchWorkspace
zarea = ZonalGeometryAsTable(rasAbove, "Value", "area_table.dbf")‍‍‍‍‍‍‍‍

Yes Dan, we know numpy is awesome!

0 Kudos