My understanding of how topographic position index is calculated is:

TPI = cell value - (mean of cell values within defined neighborhood)

But, I see that Weiss' original poster (http://www.jennessent.com/downloads/tpi-poster-tnc_18x22.pdf) was a little bit different than this.

tpi = int((dem - focalmean(dem, annulus, irad, orad)) + .5)

This part is essentially what I described - (dem - focalmean(dem, annulus, irad, orad). The annualus, irad, and orad terms just allow for an annulus of a defined size to be used rather than a continuous neighborhood.

Why is the "+.5" included and the "int()"? Weiss stated, "This poster presents an algorithm, implemented in GRID." I'm not familiar with GRID, was "int()" a function to integer-ize a value?

SAGA cites Weiss' posted for the calculation of TPI, does that mean that the algorithm in SAGA uses the "int()" and "+.5"?

  • Adding a half and integerizing the result is a standard way to round floating-point values to integer. – Vince Jul 3 at 20:42
  • @Vince, what is the logic behind adding .5 before integerizing? – nateroe Jul 3 at 20:53
  • What would happen to the values 2.99, 2.75, and 2.50 if you didn't? – Vince Jul 3 at 21:02
  • From my understanding, if you did not at .5, the final values would be 3, 3, and 3. If you did at .5, the values would become 3.49, 3.25, and 3.00 and after integerizing the final values would be 3, 3, and 3. What am I missing? – nateroe Jul 3 at 23:17
  • 1
    No, you'd get 2, 2, and 2. The Int function in the Grid environment truncates to the integer below the value. – Vince Jul 3 at 23:36

Your Answer

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

Browse other questions tagged or ask your own question.