• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
bobird的学习笔记
博客园    首页    新随笔    联系   管理    订阅  订阅

ArcEngine 不同图层的合并

本程序实现了对具有,并在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);

文章出处:

posted on 2013-01-14 14:55  bobird  阅读(439)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3