I am trying to calculate Terrain Roughness Index (TRI) as written up in Riley et al 1999, and have used the python code located here. However, this approach converts a raster to a numpy array and then iterates over the rows.

This can be relatively slow, so is there a way to use ArcGIS Pro to write a custom focal statistics script to calculate a TRI value for each cell over a moving window?

1 Answer 1


Honestly, I would just calculate a focal variance. Variance within a 3x3 window is very close to TRI [sqrt(sum(dev^2)]. The variance would also be more scalable than TRI which is limited to a square 3x3 window. You could use the raster calculator to calculate an algebraic approximation of the index.

ArcGIS (type) syntax:

s = FocalStatistics(dem, NbrRectangle(3, 3, MAP), "SUM", "")
d = (dem * dem)
t = FocalStatistics(d, NbrRectangle(3, 3, MAP), "SUM", "")
tri = sqrt( t + 9 * d - 2 * dem * s )

There are several geomorphometric indices available in the ArcGIS Geomorphometry & Gradient Metrics toolbox that would provide alternatives to TRI. There is an actual implementation of TRI, that provides optional corrections and standardization of the index, in the R spatialEco package available on CRAN or GitHub.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.