I already see a flaw-- the function should be more like:<br><br>float GDALSlopeHydroAlg (float* afWin, float fDstNoDataValue, void* pData)<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> <br> float pafLocalMax = afWin[0];<br><br> for ( int k = 1; k < 9; k++)<br> {<br> if (afWin[k] > pafLocalMax)<br>
{<br> pafLocalMax=afWin[k];<br> }<br> }<br> return atan(sqrt(pafLocalMax - afWin[4]) / (2*psData->scale)) * radiansToDegrees;<br>}<br><br><br><br><div class="gmail_quote">On Thu, Dec 15, 2011 at 11:49 AM, Stephen Mather <span dir="ltr"><<a href="mailto:mather.stephen@gmail.com">mather.stephen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br> 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.<br>
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:<br><br>The existing code for Horn, e.g. is:<br>
<br> dx = ((afWin[0] + afWin[3] + afWin[3] + afWin[6]) - <br> (afWin[2] + afWin[5] + afWin[5] + afWin[8]))/psData->ewres;<br><br> dy = ((afWin[6] + afWin[7] + afWin[7] + afWin[8]) - <br> (afWin[0] + afWin[1] + afWin[1] + afWin[2]))/psData->nsres;<br>
<br>I'd like something more like this (adapted from roughness):<br><br>float GDALSlopeHydroAlg (float* afWin, float fDstNoDataValue, void* pData)<br>{<br> // Hydrologic Slope is the max<br> // local slope btw center cell and adjacent cells<br>
<br> float pafLocalMax = afWin[0];<br><br> for ( int k = 1; k < 9; k++)<br> {<br> if (afWin[k] > pafLocalMax)<br> {<br> pafLocalMax=afWin[k];<br> }<br> }<br> return pafLocalMax - afWin[4];<br>
}<br><br>Any critques? Reasons to not add?<br>
<br>Best,<br>Steve<br><font color="#888888"><br>Stephen Mather<br>GIS Manager<br>Cleveland Metroparks<br>4101 Fulton Pkwy<br>Cleveland, OH<br>44144<br>
</font></blockquote></div><br>