[GRASS-user] GEM and Add-ons

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 :frowning:

Regards,

Raphael Saldanha
saldanha.plangeo@gmail.com

BRAZIL

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 :frowning:

Regards,

Raphael Saldanha
saldanha.plangeo@gmail.com

BRAZIL

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](http://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@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 :frowning:

Regards,

Raphael Saldanha
saldanha.plangeo@gmail.com

BRAZIL


Atenciosamente,

Raphael Saldanha
saldanha.plangeo@gmail.com
Lucille Ball - “The secret of staying young is to live honestly, eat slowly, and lie about your age.”

[cc-ing to the list]

On Tue, 2008-08-12 at 17:16 +0300, Nikos Alexandris wrote:

On Tue, 2008-08-12 at 17:15 +0300, Nikos Alexandris wrote:
> On Tue, 2008-08-12 at 11:03 -0300, 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 :frowning:
>
> Raphael,
>
> on a linux-box it's pretty easy because "r.colors.sttdev" is a shell
> script. I assume in this case it's the same on a winbox (not sure
> though).
>
> Copy it [1], save it as r.colors.sttdev.sh

Sorry, I think the suffix ".sh" is not required. Just save as it is
(r.colors.sttdev). Maybe you have to give proper file permissions.

> under /Your_GRASS_installation_directory/scripts (I don't know where
> GRASS is saved by default on a winbox) and execute from within the GRASS
> shell as you do with any other module.
>
> Greetings, Nikos
>
> [1]
> http://trac.osgeo.org/grass/browser/grass-addons/raster/r.colors.tools/r.colors.stddev

On Tue, 2008-08-12 at 12:26 -0300, Raphael Saldanha wrote:

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?

Try the command "r.colors.sttdev help"

No response…

On Tue, Aug 12, 2008 at 12:32 PM, Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de> wrote:

On Tue, 2008-08-12 at 12:26 -0300, Raphael Saldanha wrote:

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?

Try the command “r.colors.sttdev help”


Atenciosamente,

Raphael Saldanha
saldanha.plangeo@gmail.com
Joan Crawford - “I, Joan Crawford, I believe in the dollar. Everything I earn, I spend.”

The screen, attached.

On Tue, Aug 12, 2008 at 12:34 PM, Raphael Saldanha <saldanha.plangeo@gmail.com> wrote:

No response…

On Tue, Aug 12, 2008 at 12:32 PM, Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de> wrote:

On Tue, 2008-08-12 at 12:26 -0300, Raphael Saldanha wrote:

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?

Try the command “r.colors.sttdev help”


Atenciosamente,

Raphael Saldanha
saldanha.plangeo@gmail.com

Joan Crawford - “I, Joan Crawford, I believe in the dollar. Everything I earn, I spend.”


Atenciosamente,

Raphael Saldanha
saldanha.plangeo@gmail.com
Johnny Carson - “I was so naive as a kid I used to sneak behind the barn and do nothing.”

(attachments)

screen.GIF

On Dienstag, 12. August 2008 17:26:37 you wrote:

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?

yes, but easier just do:

sh r.colors.stddev --help

or look at line 16-35 there you finde 'input', 'key: b' and 'key:z' and the
corresponding description below it. But just the input is required hence

sh r.colors.stddev input=YOUR_RASTER

should work.

Martin

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@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 :frowning:
> >
> >
> >
> > Regards,
> >
> > Raphael Saldanha
> > saldanha.plangeo@gmail.com
> >
> > BRAZIL

--
**********************************************************************

University of Wuerzburg
Institute of Geography
Department of Remote Sensing
Remote Sensing and Biodiversity Unit
Am Hubland
97074 Wuerzburg, Germany
@
German Aerospace Center (DLR)
German Remote Sensing Data Center (DFD)

Phone: +49-(0)931-888-4797
Fax: +49-(0)931-888-4961
Email: martin.wegmann@uni-wuerzburg.de

**********************************************************************

ah, you are working under Windows.
Well sorry I have no experienced with GRASS running under MS WIndows, but try
it again with the 'sh' part:

sh r.colors.stddev ...

and you have to add the path to your script.

Martin

On Dienstag, 12. August 2008 17:36:42 you wrote:

The screen, attached.

On Tue, Aug 12, 2008 at 12:34 PM, Raphael Saldanha <

saldanha.plangeo@gmail.com> wrote:
> No response...
>
>
> On Tue, Aug 12, 2008 at 12:32 PM, Nikos Alexandris <
>
> nikos.alexandris@felis.uni-freiburg.de> wrote:
>> On Tue, 2008-08-12 at 12:26 -0300, Raphael Saldanha wrote:
>> > 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?
>>
>> Try the command "r.colors.sttdev help"
>
> --
> Atenciosamente,
>
> Raphael Saldanha
> saldanha.plangeo@gmail.com
> Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I
> earn, I spend."

--
**********************************************************************

University of Wuerzburg
Institute of Geography
Department of Remote Sensing
Remote Sensing and Biodiversity Unit
Am Hubland
97074 Wuerzburg, Germany
@
German Aerospace Center (DLR)
German Remote Sensing Data Center (DFD)

Phone: +49-(0)931-888-4797
Fax: +49-(0)931-888-4961
Email: martin.wegmann@uni-wuerzburg.de

**********************************************************************

Hi,

Nikos:

> on a linux-box it's pretty easy because "r.colors.sttdev" is a shell
> script. I assume in this case it's the same on a winbox (not sure
> though).

I too have little idea about ms-windows + Msys.

> Copy it [1], save it as r.colors.sttdev.sh
>
> Sorry, I think the suffix ".sh" is not required. Just save as it is
> (r.colors.sttdev). Maybe you have to give proper file permissions.
>
> under /Your_GRASS_installation_directory/scripts (I don't know where
> GRASS is saved by default on a winbox) and execute from within the
> GRASS shell as you do with any other module.
>
> [1]
http://trac.osgeo.org/grass/browser/grass-addons/raster/r.colors.tools/r.colors.stddev

You need to go to the end of that webpage and click one of
"Download in other formats:
    * Plain Text
    * Original Format"

i.e. get it *without* line numbers or any other cruft, those are just
for presentation on the web page.

I find the script to be very useful, I hope you do as well.

Hamish

On 12/08/08 17:26, Raphael Saldanha wrote:

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?

Have you tried clicking on 'Run (GUI)' ?

Moritz

OK!

I can get the help with:

sh C:/GRASS/scripts/r.colors.stddev --help

And run the script with:

sh C:/GRASS/scripts/r.colors.stddev input=HRC_20080528_151_B_124@PERMANENT

Running the script, I get a blank cmd, no percentages or anything, with the name “C:\GRASS\msys\sh.exe”

But works!!!

Thanks for the help!

But, the script makes a colored output, and I want a grayscale…

So, reading the code, I found this:

if [ $GIS_FLAG_Z -eq 0 ] ; then

MEAN_MINUS_2STDEV=echo "$mean $stddev" | awk '{print $1 - 2*$2}'
MEAN_PLUS_2STDEV=echo "$mean $stddev" | awk '{print $1 + 2*$2}'

if [ $GIS_FLAG_B -eq 0 ] ; then

smooth free floating blue/white/red

r.colors “$GIS_OPT_INPUT” color=rules << EOF
0% blue
$MEAN_MINUS_2STDEV blue
$mean white
$MEAN_PLUS_2STDEV red
100% red

The, I change to:

if [ $GIS_FLAG_Z -eq 0 ] ; then

MEAN_MINUS_2STDEV=echo "$mean $stddev" | awk '{print $1 - 2*$2}'
MEAN_PLUS_2STDEV=echo "$mean $stddev" | awk '{print $1 + 2*$2}'

if [ $GIS_FLAG_B -eq 0 ] ; then

smooth free floating blue/white/red

r.colors “$GIS_OPT_INPUT” color=rules << EOF
0% black
$MEAN_MINUS_2STDEV black
$mean grey
$MEAN_PLUS_2STDEV white
100% white

But the output turns the colors to a light grey filter or something… how can I maintain the black pure black?

On Wed, Aug 13, 2008 at 4:22 AM, Moritz Lennert <mlennert@club.worldonline.be> wrote:

On 12/08/08 17:26, Raphael Saldanha wrote:

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?

Have you tried clicking on ‘Run (GUI)’ ?

Moritz


Atenciosamente,

Raphael Saldanha
saldanha.plangeo@gmail.com
Lucille Ball - “The secret of staying young is to live honestly, eat slowly, and lie about your age.”