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