Hello,
I am attempting to use update search cursor to calculate the slope of a line. I am using SHAPE@Z to get the elevation of a point along a line. I am trying to get specific point information using queryPointAndDistance OR positionAlongLine, but I don't know which to use.
For my purposes I need the first point, middle point and end point to calculate the side slopes of a stream. I am using the following script using ArcPro to get the slope for just the left side for now.
def get_slope(lines,id_field):
"""Get the slope of the transects using the first middle and last point of the line"""
with arcpy.da.UpdateCursor(lines,[id_field,'SHAPE@Z','slope']) as cursor:
for row in cursor:
# difference in 1st point and mid-point. 100 represents the length between points
row[2]=((row[1].queryPointAndDistance(0.0,TRUE))-(row[1].queryPointAndDistance(0.5,TRUE)))/100
cusor.updateRow(row)
But I keep getting errors that 'float' object has no attribute 'positionAlongLine'. I am thinking I am missing something big...
Any help would be great.
Thanks!