mirror values at edges

Lars Schylberg larss at fmi.kth.se
Thu Oct 29 12:53:12 EST 1992

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.

#  $1 = first argument which should be a cell file


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 Schylberg                    Email: larss at 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

More information about the grass-dev mailing list