I have a DEM and a series of points. I'd like to measure the change in slope along the series of points. Distinguishing between uphill and downhill slopes matter to me, and ArcGIS' slope function renders all slopes as absolute values.
I'm working with ArcGIS' Spatial Analyst and 3D Analyst toolkits.
This is what I've done so far.
- Created points
- Run the "interpolate shape" tool
- Run the "slope" tool
- Run the "extract multi values to points" tool to add two fields Elevation and Slope to the points feature class.
I have followed the advice here (http://blogs.esri.com/esri/supportcenter/2012/03/09/calculating-the-slope-of-a-hiking-trail/) to change the downhill slope values into negatives, but have not succeeded. When I run the code (below), nothing happens.
fc = r"C:\Points\Test.gdb\Points_3d"
cursor = arcpy.da.UpdateCursor (fc, ["Elevation","Slope"])
firstRun = True
for row in cursor:
if firstRun:
oldValue = row[0]
firstRun = False
else:
if oldValue < row[0]:
row[1] = row[1]
else:
row[1] = (-1)*row[1]
oldValue = row[0]
cursor.updateRow(row)
del row
del cursor