示例#1
0
        public void ReturnIndentityFeatureClass(IFeatureClass pInputFeatureClass, IFeatureClass pIndentityFeatureClass, string savePath)
        {
            //构造Geoprocessor
            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            //设置参数
            //ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity(pdic[this.comboBoxEx1.SelectedItem.ToString()], pdic[this.comboBoxEx2.SelectedItem.ToString()], this.textBoxX1.Text);
            //ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity((IFeatureLayer)pdicLayer[this.comboBoxEx1.SelectedItem.ToString()], (IFeatureLayer)pdicLayer[this.comboBoxEx2.SelectedItem.ToString()], this.textBoxX1.Text);
            //ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity(pInputFeatureClass, pIndentityFeatureClass, this.textBoxX1.Text);

            ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity();
            //设置参数  方法一:直接用完整路径加文件名和扩展名
            //indentity.in_features = pdic[this.comboBoxEx1.SelectedItem.ToString()];
            //indentity.identity_features = pdic[this.comboBoxEx2.SelectedItem.ToString()];
            //indentity.out_feature_class = this.textBoxX1.Text;
            //设置参数  方法二:直接用featureclass名称也行
            indentity.in_features       = pInputFeatureClass;
            indentity.identity_features = pIndentityFeatureClass;
            indentity.out_feature_class = savePath;

            indentity.join_attributes = "ALL";

            //执行Intersect工具
            object sev = null;

            try
            {
                gp.Execute(indentity, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(gp.GetMessages(ref sev));
            }
        }
示例#2
0
        private void btnIndentity_Click(object sender, EventArgs e)
        {
            //构造Geoprocessor
            Geoprocessor gp = new Geoprocessor();

            gp.OverwriteOutput = true;
            //设置参数


            ILayer        pInputFeaturelayer     = GetLayerByName(pMapControl.Map, this.comboBoxEx1.SelectedItem.ToString());
            ILayer        pIndentityFeaturelayer = GetLayerByName(pMapControl.Map, this.comboBoxEx2.SelectedItem.ToString());
            IFeatureClass pInputFeatureClass     = (pInputFeaturelayer as IFeatureLayer).FeatureClass;
            IFeatureClass pIndentityFeatureClass = (pIndentityFeaturelayer as IFeatureLayer).FeatureClass;

            //ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity(pdic[this.comboBoxEx1.SelectedItem.ToString()], pdic[this.comboBoxEx2.SelectedItem.ToString()], this.textBoxX1.Text);
            //ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity((IFeatureLayer)pdicLayer[this.comboBoxEx1.SelectedItem.ToString()], (IFeatureLayer)pdicLayer[this.comboBoxEx2.SelectedItem.ToString()], this.textBoxX1.Text);
            //ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity(pInputFeatureClass, pIndentityFeatureClass, this.textBoxX1.Text);

            ESRI.ArcGIS.AnalysisTools.Identity indentity = new ESRI.ArcGIS.AnalysisTools.Identity();
            //设置参数  方法一:直接用完整路径加文件名和扩展名
            //indentity.in_features = pdic[this.comboBoxEx1.SelectedItem.ToString()];
            //indentity.identity_features = pdic[this.comboBoxEx2.SelectedItem.ToString()];
            //indentity.out_feature_class = this.textBoxX1.Text;
            //设置参数  方法二:直接用featureclass名称也行
            indentity.in_features       = pInputFeatureClass;
            indentity.identity_features = pIndentityFeatureClass;
            indentity.out_feature_class = this.textBoxX1.Text;


            indentity.join_attributes = "ALL";

            //执行Intersect工具

            object sev = null;

            try
            {
                // Execute the tool.
                gp.Execute(indentity, null);
                MessageBox.Show("标识叠加成功!");
            }
            catch (Exception ex)
            {
                // Print geoprocessing execution error messages.
                //     Return all of the message descriptions of the last tool executed.
                //显示全部信息:关键中的关键
                MessageBox.Show(gp.GetMessages(ref sev));
            }
        }