[GIS] Calculating Stream Length-gradient Index (Hack Index) with the field calculator

arcgis-10.1arcgis-desktopfield-calculatorpython

I'm trying to calculate the Stream Length-Gradient Index of a stream (example data below). Just started to get into python, but am struggling with a solution to this problem. I have 42 streams to run this code on and doing it by with excel is tedious. The stream is broken up into segments and I'd like to get a SL index for each stream.

The equation: SL = (10/Length of segment)*(sum(length of segments) * (length of segment/2))

In each stream attribute table I have:

Length

69.98 <– top of stream

90.228

94.206

85.429

94.039

99.095

92.983

76.736

56.657 <—-head of stream

Now the biggest hickup I have is that all the data is backwards I need to run the calculation from the head of the stream (bottom of the attribute table) to the top of the stream.

Thanks!

Best Answer

looking at the formula again, I'm realizing that there is no need for accumulation of lengths up/downstream. Makes things much simpler.

You can use Statistics to sum the length for the table/the stream in question. You can then use something like the following to capture that value

csr = arcpy.SearchCursor('TableViewOfStatsOutput)
row = csr.next()
sumLength= row.getValue("SUM_Length")

Then you should be able to write your formula into an CalculateField statement and get your answer.

Related Question