arcengine 调用arctoolbox功能的举例 spatialJoin

废话不多说,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://blog.csdn.net/lz576825608/article/details/9526447

You may also like...