rengarajpy

Update ID.

Discussion created by rengarajpy on Oct 29, 2015
Latest reply on Oct 29, 2015 by Dan_Patterson

Hello,

 

I have point Feature to the following attribute values.

 

    

OBJECTID *Shape *Point_IDPoint_Name
1PointP_001TVR
2PointP_002MS
3PointP_003CSS
4PointP_004GGG
5PointP_005FAN
6PointP_006NAP
7PointP_007TNEB
8PointP_008EB
9PointP_009GO
10PointP_010GD

 

and I have Feature to the following attribute values.

 

OBJECTID *Shape *Line_IDLine_NameL_Point_IDSHAPE_Length
1PolylineL_001HTP_0011.311433
2PolylineL-002LTP_0011.404263
3PolylineL_003LTP_0011.422833
4PolylineL-004HTP_00424.26874
5PolylineL_005LTP_00435.43787
6PolylineL-006LTP_00413.04293
7PolylineL_007HTP_00544.00131
8PolylineL-008LTP_00529.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

Outcomes