Hi all,
I have a situation in which I am trying to extend (grow) the area of a patch in a particular direction, depending on the ajacent cell. I want the patch to grow only untill it gets to a specified size ( say 20 Hectares). The trouble I have is stopping t
he> growth.
I have managed to get the patch to grow by identifying potential growth areas and runing the script below
I would appreciate any suggestion.
Thanks Joe
raster map test.g has three categories
cat value cat label
0 potenial growth
5 non growth
999 patch value#!/bin/csh -f
# r.mapcalc script to grow remnant aeras in suitable soil types.@ i=1
@ num=10
echo $i
echo "this will run through "$num, "loops "
d.erase
g.copy rast=test.g,output
#echo " now using "output.$i--
while ($i <= $num)r.mapcalc output.$i = 'if(output,output, eval(if(output[0,-1]==999|| output[0,1]==999||output[-1,0]==999||output[1,0]==999,999)))'
g.copy rast=output.$i,output
@ i++
echo $i
end
Hi Joe,
I'm not pretending to have the best answer, but I'll have a try. Area
measurements in raster maps can be made through r.stats, which will give
the numbers of pixels contained by each category. You want to have a
script that tells r.mapcalc not to grow patches that have exceeded a
certain size. You might try the following: give your patches unique
values (e.g. with r.clump) and have the mapcalc function assign the values
of the clumps to the cells that are to be 'stitched' to the patch. Run
r.stats to see which clumps are now exceeding the size of say 20
hectares and assign a new value (something like -1 or so) to these areas
with r.mapcalc. The next time you start the 'grow' function, exlude these
areas. It's not pretty, but I think it should work; I hope someone can
think of a quicker solution...
By the way, what on earth do you need a function like that for?
Philip Verhagen
--
S t i c h t i n g R A A P
Regionaal Archeologisch Archiverings Projekt
adress: Plantage Muidergracht 14
1018 TV Amsterdam
THE NETHERLANDS
phone: (31) 20 525 5835
fax: (31) 20 525 5834
e-mail: motte@xs4all.nl