I have a polyline feature class with a related table attached. Is there a good way to write the feature class line geometry to the records in the related table? Goal is to create a feature class with lines with duplicate geometry, e.g. stacked. Any py code out that can accomplish this?
Thanks!
Solved! Go to Solution.
David, With your previous code it was updating rows with Null or None Geometry to the matching rows that contained geometry. I updated your code to exclude the "None" geometry type from the dictionary so there wouldn't be an accidental overwrite to features that contained geometry.
import arcpy
inFC = r""
inFields = ['Unique_ID', 'SHAPE@']
#valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(inFC, inFields)}
valueDict = {}
for r in arcpy.da.SearchCursor(inFC, inFields):
if r[1] == None:
pass
else:
valueDict[r[0]] = r[1:]
print(valueDict)
with arcpy.da.UpdateCursor(inFC, inFields) as updateRows:
for updateRow in updateRows:
keyValue = updateRow[0]
print(keyValue)
if keyValue in valueDict:
updateRow[1] = valueDict[keyValue][0]
print(valueDict[keyValue][0])
updateRows.updateRow(updateRow)
print("Updated {}".format(keyValue))
David / Jeremy. Thank you both so much. This works!
Jason, don't forget to give credit to David since he did all of the heavy lifting. Plus I'm sure he would like the points for a correct answer.
Have a good weekend!
Please mark a response as Correct to close out the question. If multiple responses helped, pick the one that helped the most and mark the others helpful.
Yep. Special props to David for helping me this! I learned quite a bit today.
Jeremy, nice one. Why I tried to edit the dictionary comprehension i dont know. I'm sticking to iterators!
I think that may mislead others with incorrect solutions, but thanks anyway. Theres a points system??
Haha.. Can i give the points to David please? I just swooped in to fix a dictionary issue and don't deserve the correct answer points.