timiao

WHY no result was returned when using project raster geoprocessor in ArcEngine?

Discussion created by timiao on Jan 18, 2011
Latest reply on Jan 22, 2011 by timiao
Hi there,

I can use Project Raster in arctoolbox to project a raster data correctly and one result raster image file was returned. The related parameters are showed in the following picture.



BUT, I program C# in VS2008 using the same parameters as the above. And, try to run it. There is no error information and  no result returned! I am puzzled! The details is as followed
       private void button1_Click(object sender, EventArgs e)
        { 

            //output projected CS
            ISpatialReferenceFactory2 pSpatRefFact = new SpatialReferenceEnvironmentClass();
            int proCS_Type = (int)esriSRProjCSType.esriSRProjCS_World_Mercator;
            IProjectedCoordinateSystem pOutProCS = pSpatRefFact.CreateProjectedCoordinateSystem(proCS_Type);
            ISpatialReference pOutSRprj = pOutProCS as ISpatialReference;

            Geoprocessor igp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            ProjectRaster proR = new ProjectRaster();

            //construct processor            
            proR.out_coor_system = pOutSRprj;// "World_Mercator";
            proR.in_raster = @"E:\TestData\gisrs\projection\gcs_long_dem.img";
            proR.out_raster = @"E:\TestData\gisrs\projection\out2.img";
            proR.cell_size = 16.6;
            proR.resampling_type = "NEAREST";

            //execute the tool
            RunTool(igp, proR, null);            

        }
        // Function for returning the tool messages.
        private void ReturnMessages(Geoprocessor gp)
        {
            string ms = "";
            if (gp.MessageCount > 0)
            {
                for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
                {
                    ms += gp.GetMessage(Count);
                }
                MessageBox.Show(ms);
            }
        }
        private void RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC)
        {
            // Set the overwrite output option to true
            geoprocessor.OverwriteOutput = true;
            geoprocessor.AddOutputsToMap = true;
            try
            {
                //  geoprocessor.Execute(
                geoprocessor.Execute(process, null);
                ReturnMessages(geoprocessor);
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                ReturnMessages(geoprocessor);
            }

        }


My operation system is WIN7, and the version of arcengine is 9.3. Any reply will be appreciated! Thank you so much!

Outcomes