ericmweber

Does IRasterOpBase actually do anything?

Discussion created by ericmweber on Nov 6, 2012
Has anyone ever successfully used the IRasterOpBase interface to make the results of spatial analysis ops permanent? I've tried to use it in the code below with no success. It runs fine, but the output of the transformOp.Clip still just shows up in the temp folder as a grid stack, rather than in the specified workspace as a tiff as it should. The global environment setting "AvoidDataConversion" doesn't have an effect one way or the other, and shouldn't be necessary anyway, if I'm reading the documentation correctly:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/0001000003sn000000.htm

        private void ClipSpectral(BinarySample sample, string outFolder, string rasterID)
        {
            //workspace
            IWorkspaceFactory wsf = new RasterWorkspaceFactoryClass();
            IWorkspace ws = wsf.OpenFromFile(outFolder, 0);
            IWorkspaceName workspaceName = (IWorkspaceName)((IDataset)ws).FullName;

            //dataset name
            string spectRasName = rasterID + "spect.tif";
            IDatasetName spectDatasetName = new RasterDatasetNameClass();
            spectDatasetName.Name = spectRasName;
            spectDatasetName.WorkspaceName = workspaceName;

            //new transform op that writes directly to permanent raster
            ITransformationOp transformOp = new RasterTransformationOpClass();
            ((IRasterAnalysisGlobalEnvironment)transformOp).AvoidDataConversion = true;
            ((IRasterOpBase)transformOp).AddOutputDatasetName(0, spectDatasetName);

            //environment
            IRasterAnalysisEnvironment env = transformOp as IRasterAnalysisEnvironment;
            env.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, sample.SampleEnvelope, m_raster);
            env.OutSpatialReference = ((IGeoDataset)m_raster).SpatialReference;
            env.SetAsNewDefaultEnvironment();

            //clip
            IGeoDataset spectRaster = transformOp.Clip(m_raster as IGeoDataset, sample.SampleEnvelope);
        }

Outcomes