zoukankan      html  css  js  c++  java
  • AE实现不同图层的合并C#代码

     

    今天在单位做图层合并的工作,刚开始找不到相应的接口,现在解决了,放出来与大家共享
    本程序实现了对具有同类型数据结构的shapefile的图层合并,并在MapControl中显示.
                ILayer pLayer;
                IFeatureLayer pFeatureLayer;
                IFeatureClass pFeatureClass;
                IWorkspaceName pNewWSName;
                IBasicGeoprocessor pBasicGeop;
                IFeatureClassName pFeatureClassName;
                IDatasetName pDatasetName;
                IFeatureClass pOutputFeatClass;
                IFeatureLayer pOutputFeatLayer;
                IArray pArray;
                ITable pTable;
                //合并图层的集合
                pArray = new ArrayClass();
                for (int i = 0; i < this.axMapcontrol1.LayerCount;i++ )
                {
                    pLayer = this.MapC_main.get_Layer(i);
                    pArray.Add(pLayer);
                }
                //定义输出图层的fields表
                pLayer = this.MapC_main.get_Layer(0);
                pTable = (ITable)pLayer;
                pFeatureLayer=(IFeatureLayer)pLayer;
                pFeatureClass = pFeatureLayer.FeatureClass;
                //判断图层是否大于2个
                if(this..axMapcontrol1.LayerCount< 2){
                    MessageBox.Show("Table QI failed");
                    return;
                }
                //输出文件类型
                pFeatureClassName = new FeatureClassNameClass();
                pFeatureClassName.FeatureType = esriFeatureType.esriFTSimple;
                pFeatureClassName.ShapeFieldName = "Shape";
                pFeatureClassName.ShapeType = pFeatureClass.ShapeType;
                //输出shapefile的名称和位置
                pNewWSName = new WorkspaceNameClass();
                pNewWSName.WorkspaceFactoryProgID="esriDataSourcesFile.ShapefileWorkspaceFactory";
                pNewWSName.PathName = "E:\\Cshape";
                pDatasetName = (IDatasetName)pFeatureClassName;
                pDatasetName.Name = "Union_result_1";
                pDatasetName.WorkspaceName = pNewWSName;
                
                //合并图层
                pBasicGeop = new BasicGeoprocessorClass();
                pOutputFeatClass=pBasicGeop.Merge(pArray,pTable,pFeatureClassName);
                //Add the output layer to the map
                pOutputFeatLayer = new FeatureLayerClass();
                pOutputFeatLayer.FeatureClass = pOutputFeatClass;
                pOutputFeatLayer.Name = pOutputFeatClass.AliasName;
                this..axMapcontrol1.AddLayer(pOutputFeatLayer as ILayer, 0);
    版权说明

      如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
      作      者:温景良
      文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

  • 相关阅读:
    由jQuery Validation Remote验证引起的错误(MVC3 jQuery.validate.unobtrusive)
    Windows8下设置VS默认启动方式为管理员启动
    Asp.Net MVC 必备插件MVC Route Visualizer(Visual Studio 2012 版)
    2012 LinkCoder Jeffrey Richter:Win 8应用开发与.NET4.5
    WCF应用:宿主与调用纯代码示例(Host &Client code only sample)
    Nexus 7 入手风波记
    [转]使用HyperV BPA(Best Practices Analyzer最佳化分析工具)
    [转]SCVMM2012部署之一:先决条件条件准备
    [转]VMware管理员必掌握的八个HyperV功能
    [转]Installing and Configuring target iSCSI server on Windows Server 2012
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1351973.html
Copyright © 2011-2022 走看看