pauseanu

Error While using Data management Clip tool.

Discussion created by pauseanu on Nov 21, 2012
HI,

I am getting Error while cliping a rasrter image using Data management Clip too.
ex = {"Error HRESULT E_FAIL has been returned from a call to a COM component."}

code snippet is given below.I passed all the parameters based on an example.

   private object RasterClipping(IRaster raster, IFeature inputFeature, IFeatureClass maskedPolygonFeatureClass, ProcObject x, IEnvelope envPolyEnvelop, IPolygon inputPolygon)
        {
            Connections css = null;

            IWorkspace FileGDBWorkspace = null;
            IFeatureWorkspace fileFeatureWorkspace = null;
            //IDataset pDataset=null;
            object clippedRasterDataset = null;

            double dblXMin = 0.00;
            double dblXmax = 0.00;
            double dblYMax = 0.00;
            double dblYMin = 0.00;
            try
         {  
                css = new Connections();
                FileGDBWorkspace = css.ConnectDS("SHAPE", x.indsWkSpc[1]);
                fileFeatureWorkspace = (IFeatureWorkspace)FileGDBWorkspace;

                dblXMin = Convert.ToInt32(envPolyEnvelop.XMin);
                dblYMin = Convert.ToInt32(envPolyEnvelop.YMin);
                dblXmax = Convert.ToInt32(envPolyEnvelop.XMax);
                dblYMax = Convert.ToInt32(envPolyEnvelop.YMax);

                ESRI.ArcGIS.DataManagementTools.Clip rasterClip = new ESRI.ArcGIS.DataManagementTools.Clip();
               

                //rasterClip.in_raster = x.indsWkSpc[1] + "\\" + x.indsName[1];
                //rasterClip.out_raster = x.indsWkSpc[0] + "\\" + "Clipped.img";
                rasterClip.in_raster = @"D:\Input\Grids\EU\europe05.img";
                rasterClip.out_raster = @"D:\Project\TempFGDB.gdb\Clipped.img";

                //rasterClip.clipping_geometry = inputPolygon.Length.ToString();
               
                rasterClip.rectangle = dblXMin.ToString() + " " + dblYMin.ToString() + " " + dblXmax.ToString() + " " + dblYMax.ToString();
                //rasterClip.in_template_dataset = maskedPolygonFeatureClass.FeatureDataset.Workspace.PathName.ToString();
                Geoprocessor clipGeoprocessor = new Geoprocessor();
                clippedRasterDataset = clipGeoprocessor.Execute(rasterClip, null);
         }
            catch (Exception ex)
            {
                Console.WriteLine("{0}" + "  " + "{1}", ex.StackTrace, ex.Message);
            }
            return clippedRasterDataset;
        }

Outcomes