Hello,
I have point Feature to the following attribute values.
OBJECTID * | Shape * | Point_ID | Point_Name |
1 | Point | P_001 | TVR |
2 | Point | P_002 | MS |
3 | Point | P_003 | CSS |
4 | Point | P_004 | GGG |
5 | Point | P_005 | FAN |
6 | Point | P_006 | NAP |
7 | Point | P_007 | TNEB |
8 | Point | P_008 | EB |
9 | Point | P_009 | GO |
10 | Point | P_010 | GD |
and I have Feature to the following attribute values.
OBJECTID * | Shape * | Line_ID | Line_Name | L_Point_ID | SHAPE_Length |
1 | Polyline | L_001 | HT | P_001 | 1.311433 |
2 | Polyline | L-002 | LT | P_001 | 1.404263 |
3 | Polyline | L_003 | LT | P_001 | 1.422833 |
4 | Polyline | L-004 | HT | P_004 | 24.26874 |
5 | Polyline | L_005 | LT | P_004 | 35.43787 |
6 | Polyline | L-006 | LT | P_004 | 13.04293 |
7 | Polyline | L_007 | HT | P_005 | 44.00131 |
8 | Polyline | L-008 | LT | P_005 | 29.63592 |
I tried to update Point_ID Updation in Line Feature using arcpy.SpatialJoin_analysis but The output come both table values. I need only targetFeatures (Line Feature all values) + Join Feature(Point Feature Point ID only). I tried to the following code:
import arcpy
import os
workspace = r"D\Input.mdb"
outWorkspace = r"D:\Output.mdb"
targetFeatures = os.path.join(workspace, "Line_Feature")
joinFeatures = os.path.join(workspace, "Point_Feature")
outfc = os.path.join(outWorkspace, "Output_Feature")
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(targetFeatures)
fieldmappings.addTable(joinFeatures)
GISIDFieldIndex = fieldmappings.findFieldMapIndex("Point_ID")
fieldmap = fieldmappings.getFieldMap(GISIDFieldIndex)
field = fieldmap.outputField
field.name = "L_Point_ID"
field.aliasName = "L_Point_ID"
fieldmap.outputField = field
fieldmap.mergeRule = "Mode"
fieldmappings.replaceFieldMap(GISIDFieldIndex, fieldmap)
arcpy.SpatialJoin_analysis(targetFeatures, joinFeatures, outfc, "#", "#", fieldmappings)
Regards,
Raj P