[gdal-dev] Re: Slope in gdaldem

Stephen Mather mather.stephen at gmail.com
Thu Dec 15 13:35:19 EST 2011


Apologies for the flurry, one more change:

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;
    double key;

    float pafLocalMax = afWin[0];

    for ( int k = 1; k < 9; k++)
    {
        if (afWin[k] > pafLocalMax)
        {
            pafLocalMax=afWin[k];
        }
    }

    key = pafLocalMax - afWin[4];

    if (psData->slopeFormat == 1)
        return (float) (atan(sqrt(key) / (2*psData->scale)) *
radiansToDegrees);
    else
        return (float) (100*(sqrt(key) / (2*psData->scale)));
}

Best,
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111215/621c54d7/attachment.html


More information about the gdal-dev mailing list