laptop and a wrench

不具合

The field mapping object fails to return the correct ouput in the Spatial Join tool if both inputs contain field names with the same name specified in the field mapping object.

最後に公開された状態: August 25, 2014 ArcGIS for Desktop
不具合 ID 番号 NIM071958
送信されましたAugust 24, 2011
最終更新日June 5, 2024
適用対象ArcGIS for Desktop
見つかったバージョン10.0
ステータスDuplicate

参考情報

NIM071321

対処法

Create an in_memory copy of the input polygon feature class, delete the identical field used in the field mapping object, and then pass it into the spatial join.Code example below:# import modulesimport arcpy, os# Data: Specify location of test datahome = arcpy.GetParameterAsText(0) #r"<a href="file:C:/ArcGIS" target="_blank">C:\ArcGIS</a> Testing\Python Testing\957244 - Field Mapping"# Data: Local VariablespolygonFC = home + os.sep + "Polygons.shp" pointFC = home + os.sep + "Points.shp"idFieldName = "regID"scratchSJshape = "temp_sj.shp"scratchDirectory = home + os.sep + "Scratch" + os.sep# Process: Check if scratch folder exists and delete itif arcpy.Exists(scratchDirectory[:-1]): arcpy.Delete_management(scratchDirectory[:-1])# Process: Create scratch folderarcpy.CreateFolder_management(home, "Scratch") # Process: Create Field Mappings ObjectfieldMappings = arcpy.FieldMappings()index = fieldMappings.findFieldMapIndex(idFieldName)# Process: Populate Field Mapping ObjectnewFieldMap = arcpy.FieldMap()newFieldMap.addInputField(pointFC, idFieldName)newField = arcpy.Field()newField.type = "String"<a href="http://newField.name" target="_blank">newField.name</a> = "TestField"newField.aliasName = "TestField"newField.editable = 1newField.isNullable = 1newField.length = 250newFieldMap.mergeRule = "Join"newFieldMap.joinDelimiter = ", "newFieldMap.outputField = newFieldfieldMappings.addFieldMap(newFieldMap)# Process: Create polygon layer in memory and remove id fieldmemPoly = r"in_memory\polyFeature"arcpy.CopyFeatures_management(polygonFC, memPoly)arcpy.DeleteField_management(memPoly, idFieldName)# Process: Spatial join the point and polgon featuresarcpy.SpatialJoin_analysis(memPoly, pointFC, scratchDirectory + scratchSJshape, "JOIN_ONE_TO_ONE", "KEEP_ALL", fieldMappings, "INTERSECTS")# Process: Return output to model/displayarcpy.SetParameter(1, scratchDirectory + scratchSJshape)# Process: Delete in_memory featurearcpy.Delete_management(memPoly)

再現の手順

不具合 ID: NIM071958

ソフトウェア:

  • ArcGIS for Desktop

バグのステータスが変更されたときに通知を受け取る

Esri Support アプリのダウンロード

このトピックについてさらに調べる

ArcGIS エキスパートのサポートを受ける

テクニカル サポートへのお問い合わせ

Esri Support アプリのダウンロード

ダウンロード オプションに移動