空间操作

ArcEngine空间操作

接口类:ITopologicalOperator
引用空间:using ESRI.ArcGIS.Geometry;
常见空间方法:UNION、Buffer 、Intersect 、Clip、Difference

1、UNION 合并

在这里插入图片描述

示例代码
public IGeometry UnionFeature(IFeatureLayer m_roadLayer,IQueryFilter filter) {
            //开启编辑
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)(m_roadLayer.FeatureClass.FeatureDataset as IDataset).Workspace;
            try
            {
                //过滤要素
                IFeatureCursor featureCursor = m_roadLayer.FeatureClass.Search(filter, true);
                //开启编辑
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
                //第一个要素
                IFeature firstFeature = featureCursor.NextFeature();                
                IFeature pFeature;
                //合并对象
                IGeometry unionGeometry = firstFeature.ShapeCopy;
                //下一个要素(从第二个开始)
                while ((pFeature = featureCursor.NextFeature()) != null)
                {
                    // top类 合并要素
                    ITopologicalOperator topological = unionGeometry as ITopologicalOperator;
                    topological.Simplify();
                    //合并要素
                    unionGeometry = (topological).Union(pFeature.ShapeCopy);
                }
                //保存停止编辑
                workspaceEdit.StopEditing(true);
                workspaceEdit.StopEditOperation();
                return unionGeometry;
            }
            catch
            {

                return null;
            }
            finally
            {
                workspaceEdit.StopEditing(true);
                workspaceEdit.StopEditOperation();
            }         
        }

注:多要素使用 void ConstructUnion(IEnumGeometry geometries);

2、Buffer 缓冲

在这里插入图片描述

同上:IGeometry Buffer(double distance);

3、Intersect 相交

在这里插入图片描述

同上:IGeometry Intersect(IGeometry other, esriGeometryDimension resultDimension);

4、Clip 裁剪

在这里插入图片描述

同上:void Clip(IEnvelope clipperEnvelope);

5、Difference 差异

同上:IGeometry Difference(IGeometry other);
在这里插入图片描述

声明

1)文章来源项目实践,已经过作者测试验证,文章存在任何疑问或错误,请指正,感谢您的阅读!
2)转载请标注来源,谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值