format MEM? can not save temporary raster? RuntimeError: ERROR 010240:

1130
4
07-24-2013 09:04 AM
AndrewKniowski
New Contributor II
I am working with a large number of temporary rasters.  Individually they can be saved simply and without issue like
r1.save(outloc)

However, if they are combined in any way -e.g.
x = r1 + r2

and the result saved
x.save(outloc)

I receive the following error
"RuntimeError: ERROR 010240: Could not save raster dataset to in_memory\times_ras1 with output format MEM."


If I save -all- the temporary rasters before they are combined the final rasters save without issue.

Any thoughts?
Tags (2)
4 Replies
StacyRendall1
Occasional Contributor III
It may be that the raster objects do not support being added together with the plus symbol, "+".

Might be good to read the documentation, there is probably a command like (just making this up) x=arcpy.CombineRasters(r1, r2). You could check what is going on with something like:
arcpy.AddMessage(str(r1))
arcpy.AddMessage(str(r2))
x = r1 + r2
arcpy.AddMessage(str(x))

If adding is supported then you will get something the following output:
<arcpy.Raster object at kd985ujgs>
<arcpy.Raster object at gj3429gjk>
<arcpy.Raster object at v92jnb92m>

If it isn't supported the third entry will be different.
0 Kudos
RhettZufelt
MVP Frequent Contributor
I am working with a large number of temporary rasters. Individually they can be saved simply and without issue like 
r1.save(outloc)

However, if they are combined in any way -e.g. 
x = Raster(r1) + Raster(r2)

and the result saved 
x.save(outloc)

I receive the following error 
"RuntimeError: ERROR 010240: Could not save raster dataset to in_memory\times_ras1 with output format MEM." 


If I save -all- the temporary rasters before they are combined the final rasters save without issue. 

Any thoughts?


What does print outloc give you?

Might try the change in red and see if that fixes it for you. (documentation is unclear, you might need arcpy.env.workspace set an use quotes around r1 and r2. You will have to test.

R_
http://resources.arcgis.com/en/help/main/10.1/index.html#//018z00000051000000
0 Kudos
AndrewKniowski
New Contributor II
I originally had the env.workspace set to "in_memory" to speed up processing.

After changing it to a physical location the script seems to work without issue.

I am still unclear as to what the issue is however.  The same general function sequence has worked fine for me in other contexts.

Thanks.
0 Kudos
RustyRex
Occasional Contributor

I have this same problem.  Lots of rasters using in_memory.  I have even used arcpy.Delete_management to remove them when i am done, but I still get this error.

0 Kudos