// 空间分析:填挖
 private void Fill(object in_raster, object out_raster)
 {
     ESRI.ArcGIS.SpatialAnalystTools.Fill pTool = new ESRI.ArcGIS.SpatialAnalystTools.Fill()
     {
         in_surface_raster  = in_raster,
         out_surface_raster = out_raster
     };
     GP.Execute(pTool, null);
 }
Example #2
0
        public static IRaster Fill(IRaster surface, string outputPath)
        {
            var geoprocessor = GeoprocessingUtility.GetGeoprocessor(true, false, true, surface);

            var fillTool = new ESRI.ArcGIS.SpatialAnalystTools.Fill();

            fillTool.in_surface_raster  = GeoprocessingUtility.GetGPRasterObject(surface);
            fillTool.out_surface_raster = outputPath;

            string  resultPath   = GeoprocessingUtility.RunGpTool(geoprocessor, fillTool) as string;
            IRaster outputRaster = GeoprocessingUtility.GetRasterFromPath(resultPath);

            GeoprocessingUtility.ResetGeoprocessor();

            return(outputRaster);
        }
Example #3
0
        private void bt_ok_Click(object sender, EventArgs e)
        {
            //判断输入路径是否正确
            #region
            try
            {
                if (!File.Exists(tb_demnput.Text))
                {
                    MessageBox.Show("平均降水量数据输入路径不正确或文件被占用,请重新输入路径!", "提示", MessageBoxButtons.OK);
                    return;
                }
                if (Convert.ToDouble(tb_highinput.Text) < 0)
                {
                    MessageBox.Show("请输入正确的水位高程值!", "提示", MessageBoxButtons.OK);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("设置路径或水位高程值不合法,请检查!");
                return;
            }
            #endregion



            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator rc = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            Geoprocessor gp = new Geoprocessor();
            gp.OverwriteOutput = true;
            object sev = null;
            try
            {
                tb_state.Text = "正在处理……";
                //判断输入水位数据的单位
                double waterunit = 0;
                if (cb_waterunits.Text == "米(m)")
                {
                    waterunit = 1;
                }
                else
                {
                    waterunit = 0.001;
                }


                //判断输入缓冲距离及缓冲单位
                double bufferunit = 0;
                if (cb_bufferunits.Text == "米(m)")
                {
                    bufferunit = 1;
                }
                else
                {
                    bufferunit = 1000;
                }
                double[] bufferdistance = { Convert.ToDouble(nud_one.Value) * bufferunit, Convert.ToDouble(nud_two.Value) * bufferunit, Convert.ToDouble(nud_three.Value) * bufferunit, Convert.ToDouble(nud_four.Value) * bufferunit };


                //提取高程高于水位的区域
                tb_state.Text = "正在提取未淹没区域……";
                string flood_high = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_high" + System.IO.Path.GetExtension(tb_flooutput.Text);
                rc.output_raster = flood_high;
                rc.expression    = "Con(\"" + tb_demnput.Text + "\" >= (" + tb_highinput.Text + " * " + waterunit.ToString() + "),\"" + tb_demnput.Text + "\")";
                gp.Execute(rc, null);
                tb_state.Text = "未淹没区域提取完成!";


                //水文分析填洼
                tb_state.Text = "正在进行水文分析计算填洼……";
                ESRI.ArcGIS.SpatialAnalystTools.Fill fill = new ESRI.ArcGIS.SpatialAnalystTools.Fill();
                string fill_input, fill_output;
                fill_input              = flood_high;
                fill_output             = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_fill" + System.IO.Path.GetExtension(tb_flooutput.Text);
                fill.in_surface_raster  = fill_input;
                fill.out_surface_raster = fill_output;
                gp.Execute(fill, null);
                tb_state.Text = "水文分析填洼计算完成!";

                //水文分析计算流向
                tb_state.Text = "正在进行水文分析计算流向……";
                ESRI.ArcGIS.SpatialAnalystTools.FlowDirection flowdirection = new ESRI.ArcGIS.SpatialAnalystTools.FlowDirection();
                string flowdirection_input, flowdirection_output;
                flowdirection_input                     = fill_output;
                flowdirection_output                    = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_FlowDir" + System.IO.Path.GetExtension(tb_flooutput.Text);
                flowdirection.in_surface_raster         = flowdirection_input;
                flowdirection.out_flow_direction_raster = flowdirection_output;
                gp.Execute(flowdirection, null);
                tb_state.Text = "水文分析流向计算完成!";



                //水文分析计算流量
                tb_state.Text = "正在进行水文分析计算流量……";
                ESRI.ArcGIS.SpatialAnalystTools.FlowAccumulation flowaccumulation = new ESRI.ArcGIS.SpatialAnalystTools.FlowAccumulation();
                string flowaccumulation_input, flowaccumulation_output;
                flowaccumulation_input  = flowdirection_output;
                flowaccumulation_output = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_FlowAcc" + System.IO.Path.GetExtension(tb_flooutput.Text);
                flowaccumulation.in_flow_direction_raster = flowaccumulation_input;
                flowaccumulation.out_accumulation_raster  = flowaccumulation_output;
                gp.Execute(flowaccumulation, null);
                tb_state.Text = "水文分析流量计算完成!";

                //盆域分析
                tb_state.Text = "正在进行水文分析盆域分析……";
                ESRI.ArcGIS.SpatialAnalystTools.Basin basin = new ESRI.ArcGIS.SpatialAnalystTools.Basin();
                string basin_input, basin_output;
                basin_input  = flowdirection_output;
                basin_output = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_Basin" + System.IO.Path.GetExtension(tb_flooutput.Text);
                basin.in_flow_direction_raster = basin_input;
                basin.out_raster = basin_output;
                gp.Execute(basin, null);
                tb_state.Text = "水文分析盆域分析计算完成!";


                //阈值提取河流
                tb_state.Text = "正在阈值提取河流……";
                string flood_rasterriver = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_river" + System.IO.Path.GetExtension(tb_flooutput.Text);
                rc.expression    = "Con(\"" + flowaccumulation_output + "\" >= 800,1)";
                rc.output_raster = flood_rasterriver;
                gp.Execute(rc, null);
                tb_state.Text = "阈值提取河流计算完成!";

                //水文分析栅格河网矢量化
                tb_state.Text = "正在进行水文分析栅格河网矢量化……";
                ESRI.ArcGIS.SpatialAnalystTools.StreamToFeature streamtofeature = new ESRI.ArcGIS.SpatialAnalystTools.StreamToFeature();
                string streamtofeature_output;
                streamtofeature_output = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_river.shp";
                streamtofeature.in_flow_direction_raster = flowdirection_output;
                streamtofeature.in_stream_raster         = flood_rasterriver;
                streamtofeature.out_polyline_features    = streamtofeature_output;
                gp.Execute(streamtofeature, null);
                tb_state.Text = "水文分析栅格河网矢量化计算完成!";


                //多环缓冲区
                tb_state.Text = "正在计算多环缓冲区……";
                ESRI.ArcGIS.AnalysisTools.MultipleRingBuffer multipleringbuffer = new ESRI.ArcGIS.AnalysisTools.MultipleRingBuffer();
                string multipleringbuffer_output = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_multbuffer.shp";
                multipleringbuffer.Input_Features = streamtofeature_output;
                multipleringbuffer.Distances      = bufferdistance[0].ToString() + ";" + bufferdistance[1].ToString() + ";" + bufferdistance[2].ToString() + ";" + bufferdistance[3].ToString() + ";";
                ;
                multipleringbuffer.Buffer_Unit          = "meters";
                multipleringbuffer.Output_Feature_class = multipleringbuffer_output;
                gp.Execute(multipleringbuffer, null);
                tb_state.Text = "多环缓冲区计算完成!";


                //多环缓冲区矢量转栅格
                tb_state.Text = "正在进行多环缓冲区矢量转栅格……";
                ESRI.ArcGIS.ConversionTools.FeatureToRaster featuretoraster = new ESRI.ArcGIS.ConversionTools.FeatureToRaster();
                string featuretoraster_output = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_multbuffer" + System.IO.Path.GetExtension(tb_flooutput.Text);
                featuretoraster.in_features = System.IO.Path.GetDirectoryName(tb_flooutput.Text) + "\\" + System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "_multbuffer.shp";
                featuretoraster.field       = "distance";
                featuretoraster.out_raster  = featuretoraster_output;
                gp.Execute(featuretoraster, null);
                tb_state.Text = "多环缓冲区矢量转栅格计算完成!";


                //删除临时文件
                if (tb_state.Text == "多环缓冲区矢量转栅格计算完成!")
                {
                    string[] files = Directory.GetFiles(System.IO.Path.GetDirectoryName(tb_flooutput.Text), System.IO.Path.GetFileNameWithoutExtension(tb_flooutput.Text) + "*");
                    foreach (string file in files)
                    {
                        if (System.IO.Path.GetFileNameWithoutExtension(file) != System.IO.Path.GetFileNameWithoutExtension(basin_output) && System.IO.Path.GetFileNameWithoutExtension(file) != System.IO.Path.GetFileNameWithoutExtension(featuretoraster_output))
                        {
                            File.Delete(file);
                        }
                    }
                }


                //将结果加载显示
                #region
                string       mxfile       = System.Environment.CurrentDirectory + "\\Data\\EcoRedLine\\洪水淹没生态红线划分.mxd";
                IMapDocument pMapDocument = new MapDocumentClass();
                pMapDocument.Open(mxfile); //打开本地的地图文档,用来操作改mxd文件
                IMap              pMap                   = pMapDocument.get_Map(0);
                IMapLayers        pMapLayer              = pMap as IMapLayers;
                IRasterLayer      pRasterLayer           = new RasterLayerClass();
                IWorkspaceFactory rasterWorkspaceFactory = new RasterWorkspaceFactoryClass();
                IRasterWorkspace  rasterWorkspace        = (IRasterWorkspace)rasterWorkspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(tb_flooutput.Text), 0);

                IRasterDataset pRasterDataset1 = rasterWorkspace.OpenRasterDataset("Flood_multbuffer.tif"); //打开栅格图的文件名
                pRasterLayer.CreateFromDataset(pRasterDataset1);                                            //创建
                pRasterLayer = pMapLayer.get_Layer(0) as IRasterLayer;
                pRasterLayer.CreateFromDataset(pRasterDataset1);

                IRasterLayer   pRasterLayer2   = new RasterLayerClass();
                IRasterDataset pRasterDataset2 = rasterWorkspace.OpenRasterDataset("Flood_Basin.tif"); //打开栅格图的文件名
                pRasterLayer2.CreateFromDataset(pRasterDataset2);                                      //创建
                pRasterLayer2 = pMapLayer.get_Layer(1) as IRasterLayer;
                pRasterLayer2.CreateFromDataset(pRasterDataset2);


                pMapDocument.Save(true, true);//保存更改完路径后的mxd文件

                _PageLayoutControl.LoadMxFile(mxfile);
                _PageLayoutControl.Extent = _PageLayoutControl.FullExtent;
                _PageLayoutControl.ZoomToWholePage();


                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(gp.GetMessages(ref sev), "提示", MessageBoxButtons.OK);
            }
        }
Example #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtSoilClay.Text.Equals(""))
            {
                MessageBox.Show("请选择输入土壤黏粒含量(%)数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtSoilSlit.Text.Equals(""))
            {
                MessageBox.Show("请选择输入土壤粉粒含量(%)数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtSoilSand.Text.Equals(""))
            {
                MessageBox.Show("请选择输入土壤砂粒含量(%)数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtSoilOrganic.Text.Equals(""))
            {
                MessageBox.Show("请选择输入土壤有机物含量(%)数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtDem.Text.Equals(""))
            {
                MessageBox.Show("请选择输入DEM数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtC.Text.Equals(""))
            {
                MessageBox.Show("请选择输入地表覆被因子相关数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtP.Text.Equals(""))
            {
                MessageBox.Show("请选择输入水土保持措施因子数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtSavePath.Text.Equals(""))
            {
                MessageBox.Show("请选择结果输出路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (rbtnR.Checked && txtR.Text.Equals(""))
            {
                MessageBox.Show("请选择输入降雨侵蚀力因子R相关数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((!rbtnR.Checked) && txtPcpPath.Text.Equals(""))
            {
                MessageBox.Show("请选择输入多年平均各月降雨量数据所在路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((!rbtnR.Checked) && txtPcpPrefix.Text.Equals(""))
            {
                MessageBox.Show("请输入数据前缀(如:pcp_*)!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((!rbtnR.Checked) && txtPcpSuffix.Text.Equals(""))
            {
                MessageBox.Show("请输入数据后缀(如:tif)!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((!rbtnR.Checked) && txtYear.Text.Equals(""))
            {
                MessageBox.Show("请输入年平均降水量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //现创建一个存放临时文件的临时文件夹
            string newPath = System.IO.Path.Combine(Temfile, "");

            System.IO.Directory.CreateDirectory(newPath);

            this.rtxtState.AppendText("正在执行,请您耐心等待...\n");
            this.rtxtState.ScrollToCaret();
            this.rtxtState.AppendText("开始准备配置文件...\n");
            this.rtxtState.ScrollToCaret();
            IVariantArray parameters = new VarArrayClass();
            Geoprocessor  GP         = new Geoprocessor();

            this.rtxtState.AppendText("准备调用GP工具箱...\n");
            this.rtxtState.ScrollToCaret();
            //ESRI.ArcGIS.DataManagementTools.GetRasterProperties NDVIMin = new ESRI.ArcGIS.DataManagementTools.GetRasterProperties();
            //ESRI.ArcGIS.DataManagementTools.GetRasterProperties NDVIMax = new ESRI.ArcGIS.DataManagementTools.GetRasterProperties();
            ESRI.ArcGIS.SpatialAnalystTools.Slope            slo     = new ESRI.ArcGIS.SpatialAnalystTools.Slope();//计算坡度
            ESRI.ArcGIS.SpatialAnalystTools.Fill             demFill = new ESRI.ArcGIS.SpatialAnalystTools.Fill();
            ESRI.ArcGIS.SpatialAnalystTools.FlowDirection    Filldec = new ESRI.ArcGIS.SpatialAnalystTools.FlowDirection();
            ESRI.ArcGIS.SpatialAnalystTools.FlowAccumulation DecAcc  = new ESRI.ArcGIS.SpatialAnalystTools.FlowAccumulation();
            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator sCals   = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator sCalm   = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator sCalLS  = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator sCalR   = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator sCalK   = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator sCalA   = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator sCalC   = new ESRI.ArcGIS.SpatialAnalystTools.RasterCalculator();
            //1计算参数R

            if (rbtnR.Checked)
            {
                sR = txtR.Text;
                this.rtxtState.AppendText("降水侵蚀因子R读取成功,准备计算参数K...\n");
                this.rtxtState.ScrollToCaret();
            }
            else
            {
                this.rtxtState.AppendText("开始计算参数R...\n");
                this.rtxtState.ScrollToCaret();
                string sFileName = "";
                string sYear     = txtYear.Text;
                for (int i = 1; i < 13; i++)
                {
                    sFileName = txtPcpPath.Text + "\\" + this.txtPcpPrefix.Text + i.ToString() + "." + this.txtPcpSuffix.Text;
                    strExp    = "(1.735 * Power(10,1.5 * Log10((" + "\"" + sFileName + "\"" + " * " + "\"" + sFileName + "\"" + ") /" + "\"" + txtYear.Text + "\")" + " - 0.08188))";
                    if (i < 12)
                    {
                        sR2 = sR2 + strExp + "+";
                    }
                    else
                    {
                        sR2 = sR2 + strExp;
                    }
                }
                sR3 = sR2;
                sCalR.expression = sR3;
                sR = Temfile + "\\CalR.tif";
                sCalR.output_raster = sR;
                GP.Execute(sCalR, null);
                this.rtxtState.AppendText("降水侵蚀因子R计算成功,准备计算参数K...\n");
                this.rtxtState.ScrollToCaret();
            }

            //2计算参数K
            sK = "(0.2 + 0.3 * Exp(-0.0256 *" + "\"" + txtSoilSand.Text + "\"" + "* (1.0 - " + "\"" + txtSoilSlit.Text + "\"" + " / 100.0))) * Power((" + "\"" + txtSoilSlit.Text + "\"" + " * 1.0 / (" + "\"" + txtSoilClay.Text + "\"" + " * 1.0 + " + "\"" + txtSoilSlit.Text + "\"" + " * 1.0)), 0.3) * (1.0 - 0.25 * " + "\"" + txtSoilOrganic.Text + "\"" + " * 0.58 / (" + "\"" + txtSoilOrganic.Text + "\"" + " * 0.58 + Exp(3.72 - 2.95 * " + "\"" + txtSoilOrganic.Text + "\"" + " * 0.58))) * (1.0 - (0.7 * (1.0 - " + "\"" + txtSoilSand.Text + "\"" + " / 100.0)) / ((1.0 - " + "\"" + txtSoilSand.Text + "\"" + " / 100.0) + Exp(-5.51 + 22.9 * (1.0 - " + "\"" + txtSoilSand.Text + "\"" + " / 100.0))))";
            sCalK.expression    = sK;
            CalKpath            = Temfile + "\\CalK.tif";
            sCalK.output_raster = CalKpath;
            GP.Execute(sCalK, null);
            this.rtxtState.AppendText("土壤可蚀性因子K计算成功...\n");
            this.rtxtState.ScrollToCaret();
            this.rtxtState.AppendText("准备计算地形因子LS...\n");
            this.rtxtState.ScrollToCaret();
            //3计算参数LS
            //Fill Dem
            this.rtxtState.AppendText("开始填充洼地...\n");
            this.rtxtState.ScrollToCaret();
            demFill.in_surface_raster  = txtDem.Text;
            demFill.out_surface_raster = Temfile + "\\demFill.tif";
            GP.Execute(demFill, null);
            // cal FlowDirection
            this.rtxtState.AppendText("开始计算流向...\n");
            this.rtxtState.ScrollToCaret();
            Filldec.in_surface_raster         = Temfile + "\\demFill.tif";
            Filldec.out_flow_direction_raster = Temfile + "\\FillDec.tif";
            GP.Execute(Filldec, null);
            //cal FlowAccumulation
            this.rtxtState.AppendText("开始计算流量...\n");
            this.rtxtState.ScrollToCaret();
            Filldec.in_surface_raster = Temfile + "\\FillDec.tif";
            FlowAcc = Temfile + "\\FlowAcc.tif";
            Filldec.out_flow_direction_raster = FlowAcc;
            GP.Execute(Filldec, null);

            //先计算坡度
            this.rtxtState.AppendText("开始计算坡度...\n");
            this.rtxtState.ScrollToCaret();
            slo.in_raster          = txtDem.Text;
            slo.output_measurement = "DEGREE";
            slo.z_factor           = 1;
            string sRoad1 = Temfile + "\\Slope.tif";

            slo.out_raster = sRoad1;
            GP.Execute(slo, null);//坡度计算
            //cal S
            sS = "Con(" + "\"" + sRoad1 + "\"" + " < 5,10.8 * Sin(" + "\"" + sRoad1 + "\"" + " * 3.14 / 180) + 0.03,Con(" + "\"" + sRoad1 + "\"" + " >= 10,21.9 * Sin(" + "\"" + sRoad1 + "\"" + " * 3.14 / 180) - 0.96,16.8 * Sin(" + "\"" + sRoad1 + "\"" + " * 3.14 / 180) - 0.5))";
            sCals.expression    = sS;
            Calspath            = Temfile + "\\CalS.tif";
            sCals.output_raster = Calspath;
            GP.Execute(sCals, null);
            //cal m
            sM = "Con(" + "\"" + sRoad1 + "\"" + " <= 1,0.2,Con(" + "\"" + sRoad1 + "\"" + " <= 3,0.3,Con(" + "\"" + sRoad1 + "\"" + " <= 5,0.4,0.5)))";
            sCalm.expression    = sM;
            Calmpath            = Temfile + "\\CalM.tif";
            sCalm.output_raster = Calmpath;
            GP.Execute(sCalm, null);
            //cal ls
            sLs = "\"" + Calspath + "\"" + " * Power((" + "\"" + CalKpath + "\"" + " * " + this.txtCellSize.Text + " / 22.1)," + "\"" + Calmpath + "\"" + ")";
            sCalLS.expression    = sLs;
            Callspath            = Temfile + "\\CalLS.tif";
            sCalm.output_raster  = Calmpath;
            sCalLS.output_raster = Callspath;
            GP.Execute(sCalLS, null);
            this.rtxtState.AppendText("地形因子LS计算成功...\n");
            this.rtxtState.ScrollToCaret();

            //4计算参数C
            if (rbtnVegCover.Checked)
            {
                CalCpath = txtC.Text;
                this.rtxtState.AppendText("地表覆盖因子C读取成功...\n");
                this.rtxtState.ScrollToCaret();
            }
            else
            {
                this.rtxtState.AppendText("准备计算地表覆盖因子C...\n");
                this.rtxtState.ScrollToCaret();
                //计算NDVI最小值
                //NDVIMin.in_raster = txtC.Text;
                //CalKpath = txtDem.Text + "/CalK.tif";
                //NDVIMin.property_type = "MINIMUM";
                //GP.Execute(sCalK, null);
                double         dMin = 0;
                IGeoProcessor2 gp   = new GeoProcessorClass();
                gp.OverwriteOutput = true;
                // Create a variant array to hold the parameter values.
                IVariantArray       parameters2 = new VarArrayClass();
                IGeoProcessorResult result      = new GeoProcessorResultClass();
                // Set parameter values.
                parameters2.Add(txtC.Text);
                parameters2.Add("MINIMUM");
                result = gp.Execute("GetRasterProperties_management", parameters2, null);
                dMin   = (double)result.ReturnValue;

                //计算NDVI最大值
                double         dMax = 0;
                IGeoProcessor2 gp2  = new GeoProcessorClass();
                gp2.OverwriteOutput = true;
                // Create a variant array to hold the parameter values.
                IVariantArray       parameters3 = new VarArrayClass();
                IGeoProcessorResult result3     = new GeoProcessorResultClass();
                // Set parameter values.
                parameters3.Add(txtC.Text);
                parameters3.Add("MAXIMUM");
                result3 = gp2.Execute("GetRasterProperties_management", parameters3, null);
                dMax    = (double)result3.ReturnValue;

                //最后计算C
                sC = "(" + "\"" + txtC.Text + "\"" + " - " + dMin + ") / (" + dMax + " - " + dMin + ")";
                sCalC.expression    = sC;
                CalCpath            = Temfile + "\\CalC.tif";
                sCalC.output_raster = CalCpath;
                GP.Execute(sCalC, null);
                this.rtxtState.AppendText("地表覆盖因子C计算成功...\n");
                this.rtxtState.ScrollToCaret();
            }


            //5计算P
            sP = txtP.Text;
            this.rtxtState.AppendText("读取水土保持措施因子P...\n");
            this.rtxtState.ScrollToCaret();
            //最后开始计算A=R*K*LS*C*P
            this.rtxtState.AppendText("准备计算水土流失方程...\n");
            this.rtxtState.ScrollToCaret();
            sA = "\"" + sR + "\"" + " * " + "\"" + CalKpath + "\"" + " * " + "\"" + Callspath + "\"" + " * (1 - " + "\"" + CalCpath + "\"" + ") * " + "\"" + sP + "\"";
            sCalA.expression = sA;

            sCalA.output_raster = txtSavePath.Text;
            GP.Execute(sCalA, null);
            //删除临时文件夹
            string deleteFile = Temfile;

            DeleteFolder(deleteFile);
            this.rtxtState.AppendText("计算成功,已将结果成功保存...\n");
            this.rtxtState.ScrollToCaret();
        }