[GRASS-user] GEM and Add-ons
Raphael Saldanha
saldanha.plangeo at gmail.com
Tue Aug 12 11:26:37 EDT 2008
Ok, I put the file (r.colors.sttdev) on C:\GRASS\scripts.
On the output windowm, if I enter with r.colors.sttdev and Run, seems GRASS
recognize the command. But how in the syntax to inform the input and other
parametres?
Can I found this in the code?
1 #!/bin/sh
2
############################################################################
3 #
4 # MODULE: r.colors.stddev
5 # AUTHOR: M. Hamish Bowman, Dept. Marine Science, Otago
Univeristy,
6 # New Zealand
7 # PURPOSE:
8 #
9 # COPYRIGHT: (c) 2007 Hamish Bowman, and the GRASS Development Team
10 # This program is free software under the GNU General
Public
11 # License (>=v2). Read the file COPYING that comes with
GRASS
12 # for details.
13 #
14
#############################################################################
15
16 #%Module
17 #% description: Set color rules based on stddev from a map's mean
value.
18 #% keywords: raster
19 #%End
20 #% option
21 #% key: input
22 #% type: string
23 #% gisprompt: old,cell,raster
24 #% key_desc: name
25 #% description: Name of input raster map
26 #% required: yes
27 #%end
28 #%flag
29 #% key: b
30 #% description: Color using standard deviation bands
31 #%end
32 #%flag
33 #% key: z
34 #% description: Force center at zero
35 #%end
36
37
38 if [ -z "$GISBASE" ] ; then
39 echo "You must be in GRASS GIS to run this program." 1>&2
40 exit 1
41 fi
42
43 if [ "$1" != "@ARGS_PARSED@" ] ; then
44 exec g.parser "$0" "$@"
45 fi
46
47
48 eval `r.univar -g "$GIS_OPT_INPUT"`
49 # $? is result of the eval not r.univar (???)
50 #if [ $? -ne 0 ] ; then
51 # echo "ERROR: Problem running r.univar" 1>&2
52 # exit 1
53 #fi
54
55
56 if [ $GIS_FLAG_Z -eq 0 ] ; then
57
58 MEAN_MINUS_2STDEV=`echo "$mean $stddev" | awk '{print $1 - 2*$2}'`
59 MEAN_PLUS_2STDEV=`echo "$mean $stddev" | awk '{print $1 + 2*$2}'`
60
61 if [ $GIS_FLAG_B -eq 0 ] ; then
62 # smooth free floating blue/white/red
63 r.colors "$GIS_OPT_INPUT" color=rules << EOF
64 0% blue
65 $MEAN_MINUS_2STDEV blue
66 $mean white
67 $MEAN_PLUS_2STDEV red
68 100% red
69 EOF
70 else
71 # banded free floating black/red/yellow/green/yellow/red/black
72 MEAN_MINUS_1STDEV=`echo "$mean $stddev" | awk '{print $1 - $2}'`
73 MEAN_MINUS_3STDEV=`echo "$mean $stddev" | awk '{print $1 -
3*$2}'`
74 MEAN_PLUS_1STDEV=`echo "$mean $stddev" | awk '{print $1 + $2}'`
75 MEAN_PLUS_3STDEV=`echo "$mean $stddev" | awk '{print $1 +
3*$2}'`
76
77 # reclass with labels only works for category (integer) based
maps
78 #r.reclass input="$GIS_OPT_INPUT"
output="${GIS_OPT_INPUT}.stdevs" << EOF
79
80 # >3 S.D. outliers colored black so they show up in d.histogram
w/ white background
81 r.colors "$GIS_OPT_INPUT" color=rules << EOF
82 0% black
83 $MEAN_MINUS_3STDEV black
84 $MEAN_MINUS_3STDEV red
85 $MEAN_MINUS_2STDEV red
86 $MEAN_MINUS_2STDEV yellow
87 $MEAN_MINUS_1STDEV yellow
88 $MEAN_MINUS_1STDEV green
89 $MEAN_PLUS_1STDEV green
90 $MEAN_PLUS_1STDEV yellow
91 $MEAN_PLUS_2STDEV yellow
92 $MEAN_PLUS_2STDEV red
93 $MEAN_PLUS_3STDEV red
94 $MEAN_PLUS_3STDEV black
95 100% black
96 EOF
97 fi
98
99
100 else
101 # data centered on 0 (e.g. map of deviations)
102 r.mapcalc "r_col_stdev_abs_$$ = abs($GIS_OPT_INPUT)"
103 eval `r.info -r "r_col_stdev_abs_$$"`
104
105 # current r.univar truncates percentage to the base integer
106 STDDEV2=`r.univar -eg "r_col_stdev_abs_$$" perc=95.4500 | grep
^percentile | cut -f2 -d=`
107
108 if [ $GIS_FLAG_B -eq 0 ] ; then
109 # zero centered smooth blue/white/red
110 r.colors "$GIS_OPT_INPUT" color=rules << EOF
111 -$max blue
112 -$STDDEV2 blue
113 0 white
114 $STDDEV2 red
115 $max red
116 EOF
117 else
118 # zero centered banded black/red/yellow/green/yellow/red/black
119
120 # current r.univar truncates percentage to the base integer
121 STDDEV1=`r.univar -eg "r_col_stdev_abs_$$" perc=68.2689 | grep
^percentile | cut -f2 -d=`
122 STDDEV3=`r.univar -eg "r_col_stdev_abs_$$" perc=99.7300 | grep
^percentile | cut -f2 -d=`
123
124 # >3 S.D. outliers colored black so they show up in d.histogram
w/ white background
125 r.colors "$GIS_OPT_INPUT" color=rules << EOF
126 -$max black
127 -$STDDEV3 black
128 -$STDDEV3 red
129 -$STDDEV2 red
130 -$STDDEV2 yellow
131 -$STDDEV1 yellow
132 -$STDDEV1 green
133 $STDDEV1 green
134 $STDDEV1 yellow
135 $STDDEV2 yellow
136 $STDDEV2 red
137 $STDDEV3 red
138 $STDDEV3 black
139 $max black
140 EOF
141 fi
142
143 g.remove rast="r_col_stdev_abs_$$" --quiet
144 fi
On Tue, Aug 12, 2008 at 11:50 AM, Martin Wegmann <
wegmann at biozentrum.uni-wuerzburg.de> wrote:
> Hello Raphael,
>
> just download it and call the script within the GRASS shell
>
> sh r.colors.stddev
>
> you have to define the input on the command line. The GUI won't work with
> this
> method.
>
> regards, Martin
>
>
>
>
> On Dienstag, 12. August 2008 16:03:16 Raphael Saldanha wrote:
> > Hi!
> >
> > Where can I download GEM? I'm a newbie and need to use an add-onn
> > (r.colors.stddev), can someone give some instructions?
> >
> > GRASS 6.3.0 running on Windows :-(
> >
> >
> >
> > Regards,
> >
> > Raphael Saldanha
> > saldanha.plangeo at gmail.com
> >
> > BRAZIL
>
>
>
--
Atenciosamente,
Raphael Saldanha
saldanha.plangeo at gmail.com
Lucille Ball - "The secret of staying young is to live honestly, eat
slowly, and lie about your age."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20080812/930345de/attachment-0001.html
More information about the grass-user
mailing list