Select to view content in your preferred language

Python "Ruggedness" Analysis Code

2300
11
05-26-2011 08:22 AM
RachelRodriguez
Occasional Contributor
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
Tags (2)
0 Kudos
11 Replies
ChrisBater
Deactivated User
After reading J. Evans' post, I'm not convinced this is entirely correct, but here is some code (see attached) that will at least demonstrate one way to deal with moving windows using python.

Chris
0 Kudos
TaylerHamilton
Emerging Contributor
I have returned to this thread looking for a way to calculate VRM.

I tried your ArcScript, Mark Sappington, and it worked wonders. I was using an open source GIS that had a tool for VRM built into it, but for some reason the program decided to stop working for that tool.

I highly suggest this tool (http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=F65FF927-1422-2418-A02A-EE725...) as mentioned by Mark.

Thanks for everyone's help!
0 Kudos