Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am making a code on C# to interpolate z values of a line on a DEM. Below is the code that I've written. I have also tried step by step debugging, the program works fine till the Geoprocessor execution. But on Geoprocessor execution, it crashes the ArcGIS. What could be the problem:::

IMxDocument CurrentDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Document; IMap MapSelected = CurrentDocument.FocusMap;

        //The code below is to fetch the Raster Layer having name equal to what selected in combo box
        int LayerIndex = 0;
        string LayerName;
        string comboText = (string)comboDEM.SelectedItem;

        for (int i = 0; i < MapSelected.LayerCount; i++)
        {
            LayerName = MapSelected.get_Layer(i).Name;

            if (LayerName == comboText)
            {
                LayerIndex = i;
                break;
            }
        }

        Geoprocessor GP = new Geoprocessor();
        ILayer RasterLayer = MapSelected.get_Layer(LayerIndex);

        InterpolateShape Interpolator = new InterpolateShape();
        Interpolator.in_surface = RasterLayer;

        //The code below is to fetch the Feature Layer having name equal to what is given in textbox
        string XS_Line = txtInputCrossSectionLine.Text;
        for (int i = 0; i < MapSelected.LayerCount; i++)
        {
            LayerName = MapSelected.get_Layer(i).Name;

            if (LayerName == XS_Line)
            {
                LayerIndex = i;
                break;
            }
        }

        ILayer FeatureLayer = MapSelected.get_Layer(LayerIndex);
        Interpolator.in_feature_class = FeatureLayer;
        Interpolator.out_feature_class = @"E:\For Arc GIS\Data\ResultFromTIN";

        GP.Execute(Interpolator, null);
share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.