[GRASSLIST:393] Re: Fwd: Fwd: Developing a forest fragmentation index

Hamish hamish_nospam at yahoo.com
Mon Mar 27 00:19:32 EST 2006


> I've been trying to develop the fragmentation index using GRASS
> following the suggestions from the GRASS list.  The script is a
> step-by-step process how I came up with the finalindex map.

Great to see such quick progress. This flavour of raster processing has
historically been GRASS's strongest (or at least oldest) feature.

> Probably not the best way, since this is my first effort in GRASS
> scripting and r.mapcalc.

hey, if you get to the correct answer that's what's important. Clarity
is second. Efficiency is a distant third (unless you need real-time or
it requiers weeks of time to run).

> Some concerns are:
> does r.mfilter understand mask and null values?

Don't know. NULL and MASKed cells look the same to a module AFAIK.

> what about the edges of the images?

Cells beyond the edge of the should be treated as NULL. But, again don't
know exactly what happens without testing.



hints:

1) Use r.colors to set a color for each cat number. 
e.g.
r.colors 1990veg color=rules << EOF
1 yellow
2 brown
3 grey
4 0:127:0
5 green
6 blue
EOF


2) Use r.support (or cat << EOF > $MAPSET/cats/$MAP ; text ; EOF) to
set cat names for each feature in a raster map. Then they show up in the
legend, queries, etc. Try 'r.param.scale param=feature' or r.support to 
see what a cats file should look like.


3) r.mapcalc efficiency

You can combine some of your mapcalc commands into one step to save on
intermediary maps,

> # count number of forest pixels value=1
> r.mapcalc "E = 1.0 * C"
> r.mapcalc "F = 1.0 * D"
> r.mapcalc "pf = (E/F)"

r.mapcalc << EOF
E = 1.0 * C
F = 1.0 * D
pf = (E/F)
EOF

not sure if it saves any time. for above, why not just
r.mapcalc "pf = (C*1.0/D)"
 ?


Hamish




More information about the grass-user mailing list