基于C#的ArcEngine二次开发教程(12):缓冲区分析

目录

 

1 利用ArcMap实现缓冲区分析

1.1 打开缓冲区向导工具

1.2 缓冲区分析

2 缓冲区分析常用接口

2.1 ITopologicalOperator接口

2.2 IGraphicsContainer接口

2.3 IActiveView刷新视图接口

2.4 IElement接口

3 源码实现及结果展示

3.1 实现源码

3.2 结果展示


1 利用ArcMap实现缓冲区分析

1.1 打开缓冲区向导工具

基于C#的ArcEngine二次开发教程(12):缓冲区分析_第1张图片

1.2 缓冲区分析

2 缓冲区分析常用接口

2.1 ITopologicalOperator接口

主要用于对集合图层进行操作

基于C#的ArcEngine二次开发教程(12):缓冲区分析_第2张图片

ITopologicalOperator.Buffer方法

2.2 IGraphicsContainer接口

向地图中添加图形要素

基于C#的ArcEngine二次开发教程(12):缓冲区分析_第3张图片

向图层中添加新的要素(IGraphicsContainer.AddElement):

2.3 IActiveView刷新视图接口

基于C#的ArcEngine二次开发教程(12):缓冲区分析_第4张图片

IActiveView.Refresh进行视图刷新

2.4 IElement接口

基于C#的ArcEngine二次开发教程(12):缓冲区分析_第5张图片

3 源码实现及结果展示

3.1 实现源码

private void 缓冲区分析ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IGraphicsContainer graphicscont = axMapControl1.Map as IGraphicsContainer;//添加要素

            IActiveView av = axMapControl1.Map as IActiveView;//视图刷新

            IFeatureLayer myLayer = axMapControl1.get_Layer(0) as IFeatureLayer;
            IFeatureCursor myCursor = myLayer.FeatureClass.Search(null, true);
            IFeature myFea = myCursor.NextFeature();
          
            while (myFea != null)
            {
                ITopologicalOperator myTop = myFea.ShapeCopy as ITopologicalOperator;
                //接口IGeometry和接口ITopologicalOperator都被类Point所实现,因此可以实现接口跳转
                IGeometry buffer = myTop.Buffer(0.01);//定义缓冲区半径

                IElement ele = new PolygonElementClass();
                ele.Geometry = buffer;

                graphicscont.AddElement(ele, 0);

                av.Refresh();
                myFea = myCursor.NextFeature();
            }

        }

3.2 结果展示

基于C#的ArcEngine二次开发教程(12):缓冲区分析_第6张图片

 

你可能感兴趣的:(基于C#的ArcEngine二次开发教程(12):缓冲区分析)