[GRASS-user] bilateral border query

Martin Wegmann wegmann at biozentrum.uni-wuerzburg.de
Wed Dec 12 08:09:27 EST 2007


Hello, 

I am interested to query how many borders exist in a moving window based on a 
binary raster.

e.g.:

0 1 1 
1 1 1  
1 1 1 

== 2 borders

1 1 1
1 0 1
1 1 1

== 4 border 
 
I looked into the r.fragment script by Emmanuel Sambale[1] and he uses the 
following code sniplet 

[...]
echo "computing pff values ..."
## pixels with both forest from the cardinal directions
# 0--x--0
# |  |  |
# x--x--x
# |  |  |
# 0--x--0
 
r.mapcalc "F4 = (A * A [1,0]) * (A * A [-1,0]) * (A * A [0,-1]) * (A * A 
[0,1])"
 
#count both forest pixels
r.neighbors input=F4 output=F5 method=sum size="$GIS_OPT_window"
 
# create pff map
r.mapcalc << EOF
F6 = 1.0 * F5
pff = (F6/E)
EOF

[....]

to query how many edges are in the moving window - but as far as I understood 
this script he only queries inside a 3x3 MW and not in a larger one (which 
can be specified in this script)

I want to query in a moving window all bilateral borders - that is for a 5x5 
MW a total of 76 borders to query - I don't want to do it with [1,0] ... 
[-1,0].... any idea how to look up all border properties in a moving window?

Martin


[1] 
http://esambale.wikispaces.com/fragindex?responseToken=e58d125644db65c21c6d11a1b7a1e6fa


More information about the grass-user mailing list