I started to write a script to determine neighbours for each clump in
a map. I came up with a solution were I mirror the values at all edges.
My question now is if this could be written in one r.mapcalc statement
directly, instead of these four r.mapcalc and the r.patch statement ?
I have been trying with several versions of nested if and eval statements,
but I have found no solution.
This is the script that I came up with.
---------------------------------------------------------------------
#!/bin/sh
#
# $1 = first argument which should be a cell file
CLUM=$1
echo "temp1 = if( $CLUM != $CLUM[0,1], $CLUM[0,1], 0)" | r.mapcalc
echo "temp2 = if( $CLUM != $CLUM[1,0], $CLUM[1,0], 0)" | r.mapcalc
echo "temp3 = if( $CLUM != $CLUM[0,-1], $CLUM[0,-1], 0)" | r.mapcalc
echo "temp4 = if( $CLUM != $CLUM[-1,0], $CLUM[-1,0], 0)" | r.mapcalc
r.patch i=temp1,temp2,temp3,temp4 o=edge.mirror
----------------------------------------------------------------------
Lars
Lars Schylberg Email: larss@fmi.kth.se
Department of Photogrammetry
Royal Institute of Technology Tel. +46 8 790 86 33
S-100 44 STOCKHOLM, SWEDEN Fax. +46 8 790 66 10