[gdal-dev] Re: Slope in gdaldem

Stephen Mather mather.stephen at gmail.com
Thu Dec 15 13:29:31 EST 2011


I already see a flaw-- the function should be more like:

float GDALSlopeHydroAlg (float* afWin, float fDstNoDataValue, void* pData)
{
    // Hydrologic Slope is the max
    //  local slope btw center cell and adjacent cells

    const double radiansToDegrees = 180.0 / M_PI;
    GDALSlopeAlgData* psData = (GDALSlopeAlgData*)pData;

    float pafLocalMax = afWin[0];

    for ( int k = 1; k < 9; k++)
    {
        if (afWin[k] > pafLocalMax)
        {
            pafLocalMax=afWin[k];
        }
    }
    return atan(sqrt(pafLocalMax - afWin[4]) / (2*psData->scale)) *
radiansToDegrees;
}



On Thu, Dec 15, 2011 at 11:49 AM, Stephen Mather
<mather.stephen at gmail.com>wrote:

> Hi All,
>       A colleague tipped me off to an article in Forestry Source entitled
> "When GIS Slope Isn't What You Think" showing differences between field
> measured slope values and GIS results.  The differences can be
> substantial.  The short and long of it is that local hydrologic slope is
> closer to what's used in the field by foresters than the integrated slope
> from either Horn or Zevenbergen-Thorne.
>       And so, I have a feature request.  I would like to add hydrologic
> slope to gdaldem.  This is max local slope rather than integrated 9 cell
> slope like the existing code:
>
> The existing code for Horn, e.g. is:
>
>     dx = ((afWin[0] + afWin[3] + afWin[3] + afWin[6]) -
>           (afWin[2] + afWin[5] + afWin[5] + afWin[8]))/psData->ewres;
>
>     dy = ((afWin[6] + afWin[7] + afWin[7] + afWin[8]) -
>           (afWin[0] + afWin[1] + afWin[1] + afWin[2]))/psData->nsres;
>
> I'd like something more like this (adapted from roughness):
>
> float GDALSlopeHydroAlg (float* afWin, float fDstNoDataValue, void* pData)
> {
>     // Hydrologic Slope is the max
>     //  local slope btw center cell and adjacent cells
>
>     float pafLocalMax = afWin[0];
>
>     for ( int k = 1; k < 9; k++)
>     {
>         if (afWin[k] > pafLocalMax)
>         {
>             pafLocalMax=afWin[k];
>         }
>     }
>     return pafLocalMax - afWin[4];
> }
>
> Any critques?  Reasons to not add?
>
> Best,
> Steve
>
> Stephen Mather
> GIS Manager
> Cleveland Metroparks
> 4101 Fulton Pkwy
> Cleveland, OH
> 44144
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111215/3a8e530a/attachment-0001.html


More information about the gdal-dev mailing list