So I want to calculate angles for each line feature layer using UpdateCursor method. So far I have progressed with the code but what it is doing is; it is giving the result of the last feature angle and substituting it for all the fields. I tried to avoid that function calling and now I am getting this error. I have a polyline layer in a GDB consisting of smaller line features, I want to calculate the angle as in orientation of each line feature and update them in a marked field above in the attribute table. Since I am new to this, I don't understand where I am going wrong.
Is there some other concrete method to do this?
Here is my code:
count1 = 0 spatial_Reference = arcpy.Describe(output_split_merge_fibre_drop_sheath2).shapeFieldName with arcpy.da.UpdateCursor(output_split_merge_fibre_drop_sheath2, ["Fibre_SH_D", "SHAPE@", "OBJECTID"]) as cursor: for row in cursor: shape = row count1 = count1+1 feature = row.append(shape) x1 = feature.positionAlongLine(0.51, True).firstPoint.X x2 = feature.positionAlongLine(0.49, True).firstPoint.X y1 = feature.positionAlongLine(0.51, True).firstPoint.Y y2 = feature.positionAlongLine(0.49, True).firstPoint.Y radian = math.atan2((y1 - y2), (x1 - x2)) row = str(radian) print(row) cursor.updateRow(row)
The error message I am getting is:-
AttributeError: 'NoneType' object has no attribute 'positionAlongLine'