I have a two layers, I need to transfer a field attribute to the other layer of the selected feature.
The EMS layer has a filed "SiteCity" and so does the "Ass_Parcels" layer.
I need to transfer the Ass_Parcels SiteCity attribute to the EMS's SiteCity field.
I have the following but I am not able to get it to work.
I don't get an error, but the EMs's SiteCity field doesn't get populated.
pointLayer = 'EMS'
parcel = 'Ass_Parcels'
ptCount = int(arcpy.GetCount_management(pointLayer).getOutput(0))
dsc = arcpy.Describe(pointLayer)
selection_set = dsc.FIDSet
if len(selection_set) == 0:
print "There are no features selected"
elif ptCount >= 1:
elif ptCount >= 1:
arcpy.SpatialJoin_analysis(pointLayer, parcel, sjpoints)
search_feats ={f[0]:(f[1:]) for f in arcpy.da.SearchCursor(sjpoints,'SiteCity_1')}
print(search_feats)
with arcpy.da.UpdateCursor(pointLayer,["SHAPE@","SiteCity"]) as upd_cur:
for upd_row in upd_cur:
try:
if search_feats[upd_row[0]][1] == "Sea":
upd_row[1] == "Seattle"
elif search_feats[upd_row[0]][1] == "Spo":
upd_row[1] == "Spokane"
elif search_feats[upd_row[0]][1] == "Tac":
upd_row[1] == "Tacoma"
upd_cur.updateRow(upd_row)
except:
continue