[gdal-dev] gdaldem definitions

Dominik Schneider Dominik.Schneider at Colorado.EDU
Wed Sep 24 07:20:53 PDT 2014


Thanks Even!

Dominik Schneider
o 303.735.6296 | c 518.956.3978


On Wed, Sep 24, 2014 at 5:34 AM, Even Rouault <even.rouault at spatialys.com>
wrote:

> Le lundi 22 septembre 2014 01:45:16, Dominik Schneider a écrit :
> > One correction, that should have said:
> > TPI "the central pixel is assigned the absolute difference between the
> > central pixel of a 3x3 window and mean of all pixels within the 3x3
> window"
>
> Domink,
>
> here's the relevant part of the code. Looks they match the definition
> although
> I guess there's some ambiguity sometimes if the central pixel must be take
> into account or not. The main difference between the implementation and
> Wilson
> article might be on TPI where GDAL takes the difference and not the
> absolute
> difference. AFAIR, the implementation in GDAL is similar to the one in
> GRASS,
> but there might have been changes during porting.
>
> Pixels are numbered like the following :
> [0] [1] [2]
> [3] [4] [5]
> [6] [7] [8]
>
> so [4] is the central pixel.
>
>
> /************************************************************************/
> /*                         GDALTRIAlg()                                 */
> /************************************************************************/
>
> float GDALTRIAlg (float* afWin, float fDstNoDataValue, void* pData)
> {
>     // Terrain Ruggedness is average difference in height
>     return (fabs(afWin[0]-afWin[4]) +
>             fabs(afWin[1]-afWin[4]) +
>             fabs(afWin[2]-afWin[4]) +
>             fabs(afWin[3]-afWin[4]) +
>             fabs(afWin[5]-afWin[4]) +
>             fabs(afWin[6]-afWin[4]) +
>             fabs(afWin[7]-afWin[4]) +
>             fabs(afWin[8]-afWin[4]))/8;
> }
>
>
> /************************************************************************/
> /*                         GDALTPIAlg()                                 */
> /************************************************************************/
>
> float GDALTPIAlg (float* afWin, float fDstNoDataValue, void* pData)
> {
>     // Terrain Position is the difference between
>     // The central cell and the mean of the surrounding cells
>     return afWin[4] -
>             ((afWin[0]+
>               afWin[1]+
>               afWin[2]+
>               afWin[3]+
>               afWin[5]+
>               afWin[6]+
>               afWin[7]+
>               afWin[8])/8);
> }
>
> /************************************************************************/
> /*                     GDALRoughnessAlg()                               */
> /************************************************************************/
>
> float GDALRoughnessAlg (float* afWin, float fDstNoDataValue, void* pData)
> {
>     // Roughness is the largest difference
>     //  between any two cells
>
>     float pafRoughnessMin = afWin[0];
>     float pafRoughnessMax = afWin[0];
>
>     for ( int k = 1; k < 9; k++)
>     {
>         if (afWin[k] > pafRoughnessMax)
>         {
>             pafRoughnessMax=afWin[k];
>         }
>         if (afWin[k] < pafRoughnessMin)
>         {
>             pafRoughnessMin=afWin[k];
>         }
>     }
>     return pafRoughnessMax - pafRoughnessMin;
> }
>
> Even
>
> >
> > Dominik Schneider
> > o 303.735.6296 | c 518.956.3978
> >
> >
> > On Sun, Sep 21, 2014 at 5:36 PM, Dominik Schneider <
> >
> > dominik.schneider at colorado.edu> wrote:
> > > Hi -
> > > I was reviewing the gdaldem documentation and the definitions provided
> > > seem to differ from those in the cited article (Wilson et al. 2007)
> > > For example,
> > > TRI should be "the central pixel is assigned the mean of the absolute
> > > differences between a central pixel and its surrounding cells"
> > > TPI "the central pixel is assigned the absolute difference between the
> > > central pixel of a 3x3 window and all pixels within the 3x3 window"
> > > roughness "the central pixel is assigned the largest inter-cell
> > > difference within the 3x3 window surrounding the central pixel"
> > >
> > > of course, this is assuming the algorithms are actually those presented
> > > in the publication at the 3x3 scale as opposed to those written in the
> > > documentation.
> > >
> > > I assume the source code could be checked to resolve this question?
> > >
> > > Thanks and my apologies if I misunderstood something.
> > > Dominik
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140924/418d93c8/attachment.html>


More information about the gdal-dev mailing list