<div dir="ltr">Thanks Even!<br></div><div class="gmail_extra"><br clear="all"><div><div>Dominik Schneider</div><div><div>o 303.735.6296 | c 518.956.3978 </div><div><br></div></div></div>
<br><div class="gmail_quote">On Wed, Sep 24, 2014 at 5:34 AM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le lundi 22 septembre 2014 01:45:16, Dominik Schneider a écrit :<br>
<span class="">> One correction, that should have said:<br>
> TPI "the central pixel is assigned the absolute difference between the<br>
> central pixel of a 3x3 window and mean of all pixels within the 3x3 window"<br>
<br>
</span>Domink,<br>
<br>
here's the relevant part of the code. Looks they match the definition although<br>
I guess there's some ambiguity sometimes if the central pixel must be take<br>
into account or not. The main difference between the implementation and Wilson<br>
article might be on TPI where GDAL takes the difference and not the absolute<br>
difference. AFAIR, the implementation in GDAL is similar to the one in GRASS,<br>
but there might have been changes during porting.<br>
<br>
Pixels are numbered like the following :<br>
[0] [1] [2]<br>
[3] [4] [5]<br>
[6] [7] [8]<br>
<br>
so [4] is the central pixel.<br>
<br>
<br>
/************************************************************************/<br>
/* GDALTRIAlg() */<br>
/************************************************************************/<br>
<br>
float GDALTRIAlg (float* afWin, float fDstNoDataValue, void* pData)<br>
{<br>
// Terrain Ruggedness is average difference in height<br>
return (fabs(afWin[0]-afWin[4]) +<br>
fabs(afWin[1]-afWin[4]) +<br>
fabs(afWin[2]-afWin[4]) +<br>
fabs(afWin[3]-afWin[4]) +<br>
fabs(afWin[5]-afWin[4]) +<br>
fabs(afWin[6]-afWin[4]) +<br>
fabs(afWin[7]-afWin[4]) +<br>
fabs(afWin[8]-afWin[4]))/8;<br>
}<br>
<br>
<br>
/************************************************************************/<br>
/* GDALTPIAlg() */<br>
/************************************************************************/<br>
<br>
float GDALTPIAlg (float* afWin, float fDstNoDataValue, void* pData)<br>
{<br>
// Terrain Position is the difference between<br>
// The central cell and the mean of the surrounding cells<br>
return afWin[4] -<br>
((afWin[0]+<br>
afWin[1]+<br>
afWin[2]+<br>
afWin[3]+<br>
afWin[5]+<br>
afWin[6]+<br>
afWin[7]+<br>
afWin[8])/8);<br>
}<br>
<br>
/************************************************************************/<br>
/* GDALRoughnessAlg() */<br>
/************************************************************************/<br>
<br>
float GDALRoughnessAlg (float* afWin, float fDstNoDataValue, void* pData)<br>
{<br>
// Roughness is the largest difference<br>
// between any two cells<br>
<br>
float pafRoughnessMin = afWin[0];<br>
float pafRoughnessMax = afWin[0];<br>
<br>
for ( int k = 1; k < 9; k++)<br>
{<br>
if (afWin[k] > pafRoughnessMax)<br>
{<br>
pafRoughnessMax=afWin[k];<br>
}<br>
if (afWin[k] < pafRoughnessMin)<br>
{<br>
pafRoughnessMin=afWin[k];<br>
}<br>
}<br>
return pafRoughnessMax - pafRoughnessMin;<br>
}<br>
<br>
Even<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> Dominik Schneider<br>
> o <a href="tel:303.735.6296" value="+13037356296">303.735.6296</a> | c <a href="tel:518.956.3978" value="+15189563978">518.956.3978</a><br>
><br>
><br>
> On Sun, Sep 21, 2014 at 5:36 PM, Dominik Schneider <<br>
><br>
> <a href="mailto:dominik.schneider@colorado.edu">dominik.schneider@colorado.edu</a>> wrote:<br>
> > Hi -<br>
> > I was reviewing the gdaldem documentation and the definitions provided<br>
> > seem to differ from those in the cited article (Wilson et al. 2007)<br>
> > For example,<br>
> > TRI should be "the central pixel is assigned the mean of the absolute<br>
> > differences between a central pixel and its surrounding cells"<br>
> > TPI "the central pixel is assigned the absolute difference between the<br>
> > central pixel of a 3x3 window and all pixels within the 3x3 window"<br>
> > roughness "the central pixel is assigned the largest inter-cell<br>
> > difference within the 3x3 window surrounding the central pixel"<br>
> ><br>
> > of course, this is assuming the algorithms are actually those presented<br>
> > in the publication at the 3x3 scale as opposed to those written in the<br>
> > documentation.<br>
> ><br>
> > I assume the source code could be checked to resolve this question?<br>
> ><br>
> > Thanks and my apologies if I misunderstood something.<br>
> > Dominik<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a><br>
</font></span></blockquote></div><br></div>