# Python &amp;quot;Ruggedness&amp;quot; Analysis Code

Discussion created by rrr14 on May 26, 2011
Latest reply on Jun 23, 2012 by tayler.hamilton
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.