Hi Maning,
<br/><div class='shrinkable-quote'><br/>> In the script there is an option to slect a windows size:
<br/>>
<br/>> #%option
<br/>> #% key: window
<br/>> #% type: integer
<br/>> #% description: window size default is 5
<br/>> #% answer : 5
<br/>> #% required : yes
<br/>> #%END
<br/>>
<br/>> You can modify the r.neighbors section like this:
<br/>>
<br/>> r.neighbors input=A output=C method=sum size=$GIS_OPT_window --o
<br/>> r.neighbors input=B output=D method=sum size= $GIS_OPT_window --o
</div><br/>ok, so with that I have control on the window size from r.neighbours.
<br/>That's already something. This applies well for the calculation of pf.
<br/><br/>However, for the calculation of pff I cannot use r.neighbours, because
<br/>it does not provide for counting pixel-pairs or other more complex
<br/>functions for neighbourhood relations. I had to put that into a
<br/>separate r.mapcalc expression, here e.g. to calculate the number of
<br/>'forest-forest' pairs in a 3x3 window:
<br/><br/>x--x--x
<br/>| | |
<br/>x--0--x
<br/>| | |
<br/>x--x--x
<br/><br/>r.mapcalc
<br/>"F=(        (A[ 1,-1]*A[ 1, 0])+(A[ 1, 0]*A[ 1, 1])+ # upper row horizontal pairs
<br/> (A[ 0,-1]*A[ 0, 0])+(A[ 0, 0]*A[ 0, 1])+ # midrow horizontal pairs
<br/> (A[-1,-1]*A[-1, 0])+(A[-1, 0]*A[-1, 1])+ # lower row horizontal pairs
<br/> (A[ 1,-1]*A[ 0,-1])+(A[ 0,-1]*A[-1,-1])+ # left column vertical pairs
<br/> (A[ 1, 0]*A[ 0, 0])+(A[ 0, 0]*A[-1, 0])+ # mid column vertical pairs
<br/> (A[ 1, 1]*A[ 0, 1])+(A[ 0, 1]*A[-1, 1]))" # right column vertical pairs
<br/><br/>Now I need to find out how the window size could be fitted according
<br/>to an input value (e.g. 3 for 3x3, 9 for 9x9 etc.) for this r.mapcalc
<br/>expression.
<br/><br/>Only alternative is that the user adjusts the window size manually by
<br/>adding the respective cell-pairs to the r.mapcalc expression.
<br/><br/>E.g. for a 5x5 moving window this would look like:
<br/><br/>x--x--x--x--x
<br/>| | | | |
<br/>x--x--x--x--x
<br/>| | | | |
<br/>x--x--0--x--x
<br/>| | | | |
<br/>x--x--x--x--x
<br/>| | | | |
<br/>x--x--x--x--x
<br/><br/><br/>r.mapcalc
<br/>"F=(        (A[ 2,-2]*A[ 2,-1])+(A[ 2,-1]*A[ 2, 0])+(A[ 2, 0]*A[ 2, 1])+(A[
<br/>2, 1]*A[ 2, 2])+ # upper row horizontal pairs
<br/>...
<br/>(A[ 2,-2]*A[ 1,-2])+(A[ 1,-2]*A[ 0, -2])+(A[
<br/>0,-2]*A[-1,-2])+(A[-1,-2]*A[ -2,-2])+ # left column vertical pairs
<br/>...
<br/><br/>Any ideas how to generate a general description for window-sizes with
<br/>this r.mapcalc expression?
<br/><br/>Stefan
<br/><br/><br/>Quoting maning sambale <<a href="/user/SendEmail.jtp?type=node&node=4557482&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>>:
<br/><div class='shrinkable-quote'><br/>> Dear Stefan,
<br/>>
<br/>> If i remember it right, the window size is an input to the
<br/>> r.neighbors command.
<br/>> In the script there is an option to slect a windows size:
<br/>>
<br/>> #%option
<br/>> #% key: window
<br/>> #% type: integer
<br/>> #% description: window size default is 5
<br/>> #% answer : 5
<br/>> #% required : yes
<br/>> #%END
<br/>>
<br/>> You can modify the r.neighbors section like this:
<br/>>
<br/>> r.neighbors input=A output=C method=sum size=$GIS_OPT_window --o
<br/>> r.neighbors input=B output=D method=sum size= $GIS_OPT_window --o
<br/>>
<br/>> On Sun, Feb 26, 2012 at 5:51 PM, Stefan Sylla <<a href="/user/SendEmail.jtp?type=node&node=4557482&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a>> wrote:
<br/>>> By now, the script can only calculate the forest fraction for a 3x3 window.
<br/>>> Any ideas on how to automatically generate different window-sizes would be
<br/>>> welcome.
<br/>>
<br/>>
<br/>>
<br/>> --
<br/>> cheers,
<br/>> maning
<br/>> ------------------------------------------------------
<br/>> "Freedom is still the most radical idea of all" -N.Branden
<br/>> wiki: <a href="http://esambale.wikispaces.com/" target="_top" rel="nofollow" link="external">http://esambale.wikispaces.com/</a><br/>> blog: <a href="http://epsg4253.wordpress.com/" target="_top" rel="nofollow" link="external">http://epsg4253.wordpress.com/</a><br/>> ------------------------------------------------------
<br/>>
</div><br/><br/>
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/Re-GRASS-user-r-forestfrag-AddOn-tp4557482p4557482.html">Re: [GRASS-user] r.forestfrag AddOn</a><br/>
Sent from the <a href="http://osgeo-org.1560.n6.nabble.com/Grass-Users-f3884509.html">Grass - Users mailing list archive</a> at Nabble.com.<br/>