Here&#39;s what I&#39;ve settled on.  Let me know your thoughts.  The algorithm now correctly calculates angle to lowest nearby point.  If it&#39;s a local minima, it instead calculates angle to the nearest high point, which will be a negative number, so if the user wants to nullify these or use them in additional processing steps they can.  How does adding code to gdal work?<br>
<br>Best,<br>Steve<br><br>float GDALSlopeHydroAlg (float* afWin, float fDstNoDataValue, void* pData)<br><br>{<br>    // Hydrologic Slope is the max<br>    //  local slope btw center cell and adjacent cells<br> <br>    const double radiansToDegrees = 180.0 / M_PI;<br>
    GDALSlopeAlgData* psData = (GDALSlopeAlgData*)pData;  <br>                double key;<br>               <br>    float pafLocalMin = afWin[0];<br>     float pafLocalMax = afWin[0];<br> <br>    for ( int k = 1; k &lt; 9; k++)<br>
    {<br>        if (afWin[k] &lt; pafLocalMin)<br>        {<br>            pafLocalMin=afWin[k];<br>        }<br><br>        if (afWin[k] &gt; pafLocalMax)<br>        {<br>            pafLocalMax=afWin[k];<br>        }<br>
<br>    }<br><br>    key = afWin[4] - pafLocalMin;<br><br>    if (key &lt; 0)<br>     {<br>        key = afWin[4] - pafLocalMax;<br>     }<br>               <br>    if (psData-&gt;slopeFormat == 1)<br>        return (float) (atan(sqrt(key) / (2*psData-&gt;scale)) * radiansToDegrees);<br>
    else<br>        return (float) (100*(sqrt(key) / (2*psData-&gt;scale)));<br>}