[GIS] In ArcPy, how can I save a clipped raster dataset to memory (not to file)

arcgis-10.0arcpymemory

I've been trying to clip a larger raster dataset by a polygon extent, where the resulting clipped raster dataset is saved in-memory. So far, my attempts produce vague errors.

>>> arcpy.Clip_management(in_raster="/path/to/raster_dataset.tif", rectangle="899329.78438381 1065232.74648145 912509.334774774 1080416.77223298", out_raster="in_memory/clipped", in_template_dataset="/path/to/boundary.shp", clipping_geometry="ClippingGeometry")
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 999999: Error executing function. Failed to execute (Clip).

Is there a way I can store a raster dataset in-memory?

Documentation for the VB.NET API seem to indicate it is possible beginning in Arc 9.2, and I'm using Arc 10 on my workstation.

ArcGIS 9.2 allows to create an in-memory RasterDataset where the pixels are stored in memory, this type of raster dataset has the charastics of a file RasterDataset.

Best Answer

This works for me:

arcpy.Clip_management("C12.TIF","481919 5456830 482895 5456851","in_memory/raster2","#","256","NONE")

When I first tried this, I just wrote right into the python window, I got an error. So I ran the GUI tool, and copy/pasted the 'python snippet' from that, it worked. I also tried just 'in_memory', this writes a raster named 'in_memory' to the default GDB.