I need a code which essentially... "The terrain ruggedness index (TRI) is a measurement developed by Riley, et al. (1999) to express the amount of elevation difference between adjacent cells of a digital elevation grid. The process essentially calculates the difference in elevation values from a center cell and the eight cells immediately surrounding it. Then it squares each of the eight elevation difference values to make them all positive and averages the squares. The terrain ruggedness index is then derived by taking the square root of this average, and corresponds to average elevation change between any point on a grid and it???s surrounding area."

All I could figure out was....

ssdiff = ( ( sqr ( "in_elev"(0,0) - "in_elev"(-1,-1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(0,-1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(1,-1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(1,0) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(1,1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(0,1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(-1,1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(-1,0) ) ) )

But how do I even try and translate it onto Python and into ArcMap. I have never tried to breach the ArcMap/Python boundary.

Please HELP!

Thanks, Rachel

All I could figure out was....

ssdiff = ( ( sqr ( "in_elev"(0,0) - "in_elev"(-1,-1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(0,-1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(1,-1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(1,0) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(1,1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(0,1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(-1,1) ) ) + ( sqr ( "in_elev"(0,0) - "in_elev"(-1,0) ) ) )

But how do I even try and translate it onto Python and into ArcMap. I have never tried to breach the ArcMap/Python boundary.

Please HELP!

Thanks, Rachel

This probably isn't a very good "beginner" Python project, but there are some ways of doing this in ArcGIS/Python:

1. Load the data into a Python dictionary or numpy array and write your own function (this would require some Python knowledge for sure.

2. A simpler idea is to make 8 separate grids that are each "shifted" in one of the eight directions. So for example, produce a grid shifted one pixel to the north, another shifted 1 pixel to the NE, another shifted to the E, etc. Use the "Shift" tool in ArcToolbox to do this. Name each shifted grid according to the direction of the shift - so you will have grids n, ne, e, se, s, sw, w, nw - also name your original non-shifted grid c (for center). Then use the Combine tool to overlay all the grids together. Hopefully your grids aren't too big; otherwise this might not work due to too many unique values in the combo grid... You may need to adjust the max raster attribute limit in the AdvancedArcMapSettings.exe registry editor to accomplish this. Anyway, PRESTO! In the output combo grid there will then be fields for each of the direction grids (the values representing the elevations of each cardinal direction relative to "c"). Add a new field "TRI" and just calc it according to the TRI equation.