arcengine 调用arctoolbox功能的举例 spatialJoin

本文介绍了一种使用ArcGIS进行空间连接(Spatial Join)的方法,通过C#代码实现将两个地理空间数据集根据它们的空间关系进行连接。此过程能够帮助用户理解如何设置目标特征、连接特征、输出特征类以及其他关键参数。

废话不多说,code是王道。

其中str1、str2两个参数是target路径、join路径 


 private void spatialJoin(Geoprocessor gp, string str1, string str2)

        {
            ESRI.ArcGIS.AnalysisTools.SpatialJoin sj = new ESRI.ArcGIS.AnalysisTools.SpatialJoin();


            saveName("spatialJoin", getFileName(str1) + "_SpatialJoin.shp");


            sj.target_features = str1;


            sj.join_features = str2;


            sj.out_feature_class = getPathName(str1) + "_SpatialJoin.shp";


            sj.join_operation = "JOIN_ONE_TO_ONE";


            sj.match_option = "INTERSECTS";


            sj.join_type = "KEEP_ALL";


            if (sj.join_features != null || sj.target_features != null)
            {
                IGeoProcessorResult results = null;


                results = (IGeoProcessorResult)gp.Execute(sj, null);


                IGPUtilities pGPUtil = new GPUtilitiesClass();


                IFeatureClass pFC;


                IQueryFilter pQF;


                pGPUtil.DecodeFeatureLayer(results.GetOutput(0), out pFC, out pQF);


                int count = pFC.FeatureCount(null);      //统计Feature对象个数


                IFeatureCursor pCursor = pFC.Insert(true);   //提取FeatureCursor对象


                IFeatureLayer pFeatureLayer = new FeatureLayerClass();


                pFeatureLayer.FeatureClass = pFC;


                axMapControl1.Map.AddLayer(pFeatureLayer); 


                result5.Text = "Spatial Join 完成!";


            }
            else
                MessageBox.Show("请选择图层");
        }

转载于:https://www.cnblogs.com/dyllove98/p/3220232.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值