[GRASS-user] how to store results from r.sum with script
BLANDENIER Lucien
lucien.blandenier at unine.ch
Mon Jan 13 07:20:15 PST 2014
Hello Vaclav,
I tried with the following script:
$C=$(r.sum rast=map at mapset)
$echo $C
SUM = 16116.500006
But I think the variable C stores all the command (r.sum rast=map at mapset) and not only the result. Do you know how it would be possible to store the result "SUM = 16116.500006"
Regards
Lucien
________________________________
De : Vaclav Petras [wenzeslaus at gmail.com]
Envoyé : dimanche 12 janvier 2014 03:11
À : BLANDENIER Lucien
Cc : grass-user at lists.osgeo.org
Objet : Re: [GRASS-user] how to store results from r.sum with script
Hi,
I might missed it but I don't know about r.sum module. (I know only r.sun).
Saving standard output of module (if it prints something to standard output) is the same as for any other command line tool in bash. If the output is a map (in GRASS) just use it as input to some other module (using the map name).
Examples bellow show saving outputs of echo command to variables (echo command just print its parameters to standard output, i.e. to command line). Working with numbers (additions, multiplications) can be more difficult (requires different syntax) but there should be some online guides.
Vaclav
$ A="some text"
$ echo $A
some text
$ B=`echo "this is printed to stdout"`
$ echo $B
this is printed to stdout
$ C=$(echo "this is printed to stdout")
$ echo $C
this is printed to stdout
(lines beginning with $ are lines with command which are meant to by typed into the command line, the other lines are output)
On Sat, Jan 11, 2014 at 9:32 AM, BLANDENIER Lucien <lucien.blandenier at unine.ch<mailto:lucien.blandenier at unine.ch>> wrote:
Dear all,
I would like to know if there is a way to store results of a calculation done with r.sum on many raster with a bash script.
I need to reuse these results in later calculations.
Thanks
Lucien
_______________________________________________
grass-user mailing list
grass-user at lists.osgeo.org<mailto:grass-user at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/grass-user
More information about the grass-user
mailing list