/// <param name="pFeatureClass">融合要素</param>
        /// <param name="dissField">融合字段</param>
        /// <param name="outPath">输出数据库路径</param>
        /// <param name="name">输出要素名称</param>
        private IFeatureClass Dissolve(IFeatureClass pFeatureClass, string dissField, string outPath, string name)
        {
            IFeatureClass pOutFeatureClass = null;

            try
            {
                ESRI.ArcGIS.Geoprocessor.Geoprocessor    gp        = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                ESRI.ArcGIS.DataManagementTools.Dissolve pDissolve = new ESRI.ArcGIS.DataManagementTools.Dissolve();
                gp.OverwriteOutput          = true;
                pDissolve.in_features       = pFeatureClass;
                pDissolve.dissolve_field    = dissField;
                pDissolve.out_feature_class = outPath + "\\" + name;
                pDissolve.multi_part        = "true"; //跨区域融合;

                ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 result = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2)gp.Execute(pDissolve, null);

                if (result.Status != ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)
                {
                    MessageBox.Show("操作失败!");
                    return(null);
                }
                else
                {
                    pOutFeatureClass = gp.Open(result.ReturnValue) as IFeatureClass;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("操作失败!");
                return(null);
            }
            return(pOutFeatureClass);
        }
예제 #2
0
        public IPolygon DissolvePolygon(List <IPolygon> polygons)
        {
            IPolygon result = null;

            IFeatureClass outFeatureClass = null;

            Geoprocessor gp = new Geoprocessor();

            ESRI.ArcGIS.DataManagementTools.Dissolve disTool = new ESRI.ArcGIS.DataManagementTools.Dissolve();
            disTool.in_features       = polygons;
            disTool.out_feature_class = outFeatureClass;

            gp.Execute(disTool, null);

            return(result);
        }
        private IFeatureLayer DissolveLineLayer(IFeatureLayer InFeatureLayer)
        {
            try{
            ITable dissolveTable = (ITable)InFeatureLayer;
            IDataset dataset = (IDataset)InFeatureLayer;

            ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                            ESRI.ArcGIS.DataManagementTools.Dissolve d = new ESRI.ArcGIS.DataManagementTools.Dissolve();
            d.in_features = dissolveTable;
            d.out_feature_class = System.IO.Path.Combine(dataset.Workspace.PathName, "doodie");
            d.dissolve_field = "SHAPE";
            //d.statistics_fields = "";
            d.multi_part = "MULTI_PART";
            geoprocessor.Execute(d, null);

            return d.out_feature_class as IFeatureLayer ;

            //ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            //ESRI.ArcGIS.DataManagementTools.Dissolve d = new ESRI.ArcGIS.DataManagementTools.Dissolve();
            //ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult Result;
            //IFeatureLayer pOutFeatureLayer = new FeatureLayer();

            //try
            //{

            //    geoprocessor.AddOutputsToMap = false;
            //    geoprocessor.OverwriteOutput = true;

            //    d.in_features = InFeatureLayer.Name ;
            //    d.dissolve_field = InFeatureLayer.FeatureClass.ShapeFieldName;
            //    d.out_feature_class = "Dissolve";

            //    Result = geoprocessor.Execute(d, null) as IGeoProcessorResult;

            //    pOutFeatureLayer.FeatureClass = geoprocessor.Open("Dissolve") as IFeatureClass;
            //    return pOutFeatureLayer;

            //IFeatureLayer OutFeatureLayer = new FeatureLayer();
            //IGxCatalogDefaultDatabase Defaultgdb = ArcMap.Application as IGxCatalogDefaultDatabase;

            //string g = Defaultgdb.DefaultDatabaseName.PathName;

            //ITable dissolveTable = (ITable)InFeatureLayer;
            //IDataset dataset = (IDataset)InFeatureLayer;

            //ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            //ESRI.ArcGIS.DataManagementTools.Dissolve d = new ESRI.ArcGIS.DataManagementTools.Dissolve();
            //d.in_features = dissolveTable;
            //d.out_feature_class = Defaultgdb.DefaultDatabaseName.PathName + "\\diss";
            //d.dissolve_field = InFeatureLayer.FeatureClass.ShapeFieldName;
            ////d.statistics_fields = "";
            ////d.multi_part = "MULTI_PART";
            //geoprocessor.Execute(d, null);

            //OutFeatureLayer.FeatureClass = d.out_feature_class as IFeatureClass;
            //return OutFeatureLayer;
            ////return d.out_feature_class as IFeatureClass;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                return null;
            }
        }
예제 #4
0
        private void butOk_Click(object sender, EventArgs e)
        {
            if (this.CheckingInput())
            {
                Application.DoEvents();
                this.comboxlayer.Enabled  = false;
                this.comboxFiled.Enabled  = false;
                this.textBox1.Enabled     = false;
                this.button1.Enabled      = false;
                this.butOk.Enabled        = false;
                this.progressBar1.Visible = true;
                this.progressBar1.Minimum = 0;
                this.progressBar1.Maximum = 100;

                ILayer        layer = this.MapLayer[this.comboxlayer.SelectedIndex];
                IFeatureClass pInputFeatureClass = (layer as IFeatureLayer).FeatureClass;



                try
                {
                    ESRI.ArcGIS.Geoprocessor.Geoprocessor    gp    = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                    ESRI.ArcGIS.DataManagementTools.Dissolve pDiss = new ESRI.ArcGIS.DataManagementTools.Dissolve();
                    gp.OverwriteOutput      = true;
                    pDiss.in_features       = LayerToShapefilePath(layer);
                    pDiss.dissolve_field    = comboxFiled.Text;
                    pDiss.out_feature_class = textBox1.Text + "\\" + textBox2.Text;
                    if (checkBox1.Checked)
                    {
                        pDiss.multi_part = "true";
                    }
                    else
                    {
                        pDiss.multi_part = "false";
                    }

                    /////
                    for (int i = 0; i < 20; i++)
                    {
                        this.progressBar1.Value++;
                    }
                    /////////////
                    ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 result = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2)gp.Execute(pDiss, null);
                    /////
                    for (int i = 0; i < 20; i++)
                    {
                        this.progressBar1.Value++;
                    }
                    /////////////
                    if (result.Status != ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)
                    {
                        MessageBox.Show("操作失败!");
                        this.Close();
                    }
                    else
                    {
                        /////
                        for (int i = 0; i < 20; i++)
                        {
                            this.progressBar1.Value++;
                        }
                        /////////////
                        //获取结果
                        IFeatureClass resultFClass = gp.Open(result.ReturnValue) as IFeatureClass;
                        IFeatureLayer pLayer       = new FeatureLayerClass
                        {
                            FeatureClass = resultFClass,
                            Name         = resultFClass.AliasName
                        };
                        /////
                        for (int i = 0; i < 20; i++)
                        {
                            this.progressBar1.Value++;
                        }
                        /////////////
                        this.m_axMapControl.AddLayer(pLayer);
                        this.m_axMapControl.ActiveView.Refresh();
                        MessageBox.Show(pLayer.Name + "处理完成!");
                        base.Close();
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("操作失败!");
                    this.Close();
                }
            }
        }
        private IFeatureLayer DissolveLineLayer(IFeatureLayer InFeatureLayer)
        {
            try{
                ITable   dissolveTable = (ITable)InFeatureLayer;
                IDataset dataset       = (IDataset)InFeatureLayer;

                ESRI.ArcGIS.Geoprocessor.Geoprocessor    geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                ESRI.ArcGIS.DataManagementTools.Dissolve d            = new ESRI.ArcGIS.DataManagementTools.Dissolve();
                d.in_features       = dissolveTable;
                d.out_feature_class = System.IO.Path.Combine(dataset.Workspace.PathName, "doodie");
                d.dissolve_field    = "SHAPE";
                //d.statistics_fields = "";
                d.multi_part = "MULTI_PART";
                geoprocessor.Execute(d, null);

                return(d.out_feature_class as IFeatureLayer);


                //ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                //ESRI.ArcGIS.DataManagementTools.Dissolve d = new ESRI.ArcGIS.DataManagementTools.Dissolve();
                //ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult Result;
                //IFeatureLayer pOutFeatureLayer = new FeatureLayer();



                //try
                //{

                //    geoprocessor.AddOutputsToMap = false;
                //    geoprocessor.OverwriteOutput = true;

                //    d.in_features = InFeatureLayer.Name ;
                //    d.dissolve_field = InFeatureLayer.FeatureClass.ShapeFieldName;
                //    d.out_feature_class = "Dissolve";

                //    Result = geoprocessor.Execute(d, null) as IGeoProcessorResult;

                //    pOutFeatureLayer.FeatureClass = geoprocessor.Open("Dissolve") as IFeatureClass;
                //    return pOutFeatureLayer;



                //IFeatureLayer OutFeatureLayer = new FeatureLayer();
                //IGxCatalogDefaultDatabase Defaultgdb = ArcMap.Application as IGxCatalogDefaultDatabase;


                //string g = Defaultgdb.DefaultDatabaseName.PathName;

                //ITable dissolveTable = (ITable)InFeatureLayer;
                //IDataset dataset = (IDataset)InFeatureLayer;

                //ESRI.ArcGIS.Geoprocessor.Geoprocessor geoprocessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
                //ESRI.ArcGIS.DataManagementTools.Dissolve d = new ESRI.ArcGIS.DataManagementTools.Dissolve();
                //d.in_features = dissolveTable;
                //d.out_feature_class = Defaultgdb.DefaultDatabaseName.PathName + "\\diss";
                //d.dissolve_field = InFeatureLayer.FeatureClass.ShapeFieldName;
                ////d.statistics_fields = "";
                ////d.multi_part = "MULTI_PART";
                //geoprocessor.Execute(d, null);

                //OutFeatureLayer.FeatureClass = d.out_feature_class as IFeatureClass;
                //return OutFeatureLayer;
                ////return d.out_feature_class as IFeatureClass;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                return(null);
            }
        }