ArcGIS GP 调用Intersect的参数传入方法 C#

 

  /// <summary>
        /// 调用GP工具对两个要素类做相交处理
        /// </summary>
        /// <param name="featureClass1">优先级为1的要素类</param>
        /// <param name="featureClass2">优先级为2的要素类</param>
        /// <param name="outFeatureClassPath">输出结果要素类路径</param>
        private void DoIntersect(IFeatureClass featureClass1,IFeatureClass featureClass2,string outFeatureClassPath)
        {
            Geoprocessor gp = new Geoprocessor
            {
                AddOutputsToMap = false,
                OverwriteOutput = true
            };
            IGpValueTableObject gpValueTable = new GpValueTableObjectClass();
            gpValueTable.SetColumns(2);
            object rank = 1;
            object row = featureClass1;
            gpValueTable.SetRow(0, ref row);
            gpValueTable.SetValue(0, 1, ref rank);
            rank = 2;
            row = featureClass2;
            gpValueTable.SetRow(1, ref row);
            gpValueTable.SetValue(1, 1, ref rank);
            Intersect intersect = new Intersect
            {
                in_features = gpValueTable,
                out_feature_class = outFeatureClassPath,
                join_attributes = "ALL",
                output_type = "INPUT"
            };
            if (gp.Execute(intersect, null) == null)
                throw new Exception("数据预处理失败!");
        }

 

posted @ 2020-05-17 20:31  yzhyingcool  阅读(662)  评论(0编辑  收藏  举报