Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using IExtractionOp to clip a raster by polygon:

IExtractionOp operation = (IExtractionOp)(new RasterExtractionOp());
IRasterBandCollection rasterBandCollection = (IRasterBandCollection)operation.Polygon((IGeoDataset)rasterDataset, polygon, true);

I tried saving via

// Fails with exception
IRasterDataset dataset = rasterBandCollection.Item(0).RasterDataset;
dataset.Copy("temp" + extension, (IWorkspace)rasterWorkspace);

// Successful, but does not show any pixels in ArcMap when opened
rasterBandCollection.SaveAs("temp" + extension, (IWorkspace)rasterWorkspace, rasterDataset.Format);

// Same result as SaveAs
((ITemporaryDataset)dataset).MakePermanentAs("temp" + extension, (IWorkspace)rasterWorkspace, rasterDataset.Format);

None of the three methods above worked... I can use the returned result and add it to the map, so the extraction seems to be valid, but I'm unable to store it anyhow.

share|improve this question
Did you try setting IRasterAnalysisEnvironment.OutputWorkspace on the RasterExtractionOp? – Kirk Kuykendall Mar 18 '13 at 19:43
Thank you - you gave me the successful hint:… - I will post an answer later... – Dresel Mar 18 '13 at 22:03
up vote 2 down vote accepted

With ArcGIS 10 there a two documentated possibilities:

Using ITemporaryDataset.MakePermanentAs as documentated here.

This however leads to the result described above - a very small (unuseable) file is generated. I noticed that sometimes the file changes to a usable file after the debug process is closed (respectively ArcMap). I found out that explicitly freeing the result of MakePermanentAs leads to the same result, which is an acceptable workaround for me.

IDataset raster = temporaryDataset.MakePermanentAs(filename, (IWorkspace)rasterWorkspace, format);

// Free result explicitly (workaround)

Second possibility is to use IRasterOPBase as described here:

// Creates RasterDatasetName object as output dataset name
IDatasetName datasetName = (IDatasetName)new RasterDatasetName();
datasetName.WorkspaceName = (IWorkspaceName)((IDataset)rasterWorkspace).FullName;
datasetName.Name = filename;

// Adds output dataset name to Op (force 10 execution path)
IRasterOpBase rasterOpBase = (IRasterOpBase)operation;
rasterOpBase.AddOutputDatasetName(0, datasetName);

This however randomly fails when using it in a STA Thread - so I have to stick with solution number one.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.