SptialJoin样例函数

Posted cuijy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SptialJoin样例函数相关的知识,希望对你有一定的参考价值。

  在开发的Arcmap插件或软件时,调用SptialJoin工具时,经常程序经常会弹出异常。在这个随笔里面贴一个可以顺利运行的函数,方便后续的开发。

 

//tarFC 目标图层 joinFC 添加图层 path_spatialJoin 成果图层输出路径 

 private void SptialJoin(IFeatureClass tarFC, IFeatureClass joinFC, string path_spatialJoin)
        
            int index_JoinOidFd = joinFC.Fields.FindField("ORIG_FID");
            IField joinFd = joinFC.Fields.get_Field(index_JoinOidFd);
            IFieldEdit pNewField = new FieldClass();
            pNewField.Name_2 = "Alp_Join";
            pNewField.Type_2 = esriFieldType.esriFieldTypeString;
            pNewField.Length_2 = 2000;

            int index_SrcTBYBHFd = tarFC.FindField("TBYBH");
            IField srcFd = tarFC.Fields.get_Field(index_SrcTBYBHFd);
            IFieldEdit pSrcField = new FieldClass();
            pSrcField.Name_2 = "TBYBH";
            pSrcField.Type_2 = esriFieldType.esriFieldTypeString;
            pSrcField.Length_2 = 100;


            IGPUtilities pGpUtilities = new GPUtilitiesClass();
            IArray pInputTables = new ArrayClass();
            IGPFieldMapping pFieldMapping = new GPFieldMappingClass();


            IDETable pInputTableB = new DETableClass();
            pInputTables.Add(pInputTableB);
            pFieldMapping.RemoveAll();
            pFieldMapping.Initialize(pInputTables, null);


            IGPFieldMap pFieldMap = new GPFieldMapClass();
            pFieldMap.MergeRule = esriGPFieldMapMergeRule.esriGPFieldMapMergeRuleJoin;
            pFieldMap.JoinDelimiter = ",";
            pFieldMap.AddInputField(pInputTableB, joinFd, -1, -1);
            pFieldMap.OutputField = pNewField as IField;
            pFieldMapping.AddFieldMap(pFieldMap);

            pFieldMap = new GPFieldMapClass();
            pFieldMap.MergeRule = esriGPFieldMapMergeRule.esriGPFieldMapMergeRuleFirst;
            pFieldMap.JoinDelimiter = ",";
            pFieldMap.AddInputField(pInputTableB,srcFd,-1,-1);
            pFieldMap.OutputField = pSrcField as IField;
            pFieldMapping.AddFieldMap(pFieldMap);

            GpHelper.SpatialJoin(tarFC, joinFC, path_spatialJoin, "JOIN_ONE_TO_ONE", "INTERSECT", "KEEP_ALL", pFieldMapping);
        

  

以上是关于SptialJoin样例函数的主要内容,如果未能解决你的问题,请参考以下文章

cpp虚函数纯需函数样例

Scala:样例类模式匹配Option偏函数泛型

[PTA]实验3-2 计算符号函数的值

字符串-实现strcmp函数(字符串比较)

Python线程的用法 函数式线程_thread和threading 样例

函数指针使用演示样例(參考Linux-内核代码)