[STATSGRASS] raster cross-stats
Markus Neteler
neteler at itc.it
Sun Dec 30 17:43:36 EST 2001
On Fri, Dec 14, 2001 at 10:15:14AM +0100, Roger Bivand wrote:
> On Thu, 13 Dec 2001, Markus Neteler wrote:
>
> > Sorry for a FAQ, but (due to my current traveling with temporal
> > internet access) how can I specify a parameter such as
> > $1 in shell scripts?
> > I want to add parameters to the scripts which are visible within
> > R BATCH. If you could point me to a online document
> > I would be glad.
> >
> If $1 is a shell variable, then it is visible - here are some lines from
> the r.statistics.R shell script:
>
> > > layer=$1
> > >
> > > method=$2
>
> > > R --vanilla --quiet --slave << EOF
> > > library(GRASS)
> > > print($method(rast.get(gmeta(), "$layer")[[1]]))
> > > EOF
> > >
>
> If you need to use $ as an R symbol - maps$elev say - then normal shell
> script rules should apply? Escape with a backslash? map\$elev I guess?
>
> R CMD BATCH wants an input file, doesn't it (haven't used it
> myself) rather than redirection from stdin as above? Then you would echo
Dear Roger,
now I am back (unfortunately under pressure) with this question:
In fact I want to run
R CMD BATCH
I have a small text file (Rbatchfile):
library(GRASS)
G <- gmeta()
mapname <- "$1"
map <- rast.get(G, mapname)
map.frame <- data.frame(east(G), north(G), map$mapname)
summary(map.frame)
Then I run the batch job:
R BATCH Rbatchfile aspect
cat aspect # for some reason stored into this filename
[...]
Running in /usr/local/share/grassdata/spearfish/user1
> G <- gmeta()
> mapname <- "$1"
> map <- rast.get(G, mapname)
Error in rast.get(G, mapname) : raster map: $1 not found
Execution halted
When hard-coding the map name in the text file, everything runs
well. But I don't get it flexible.
Perhaps someone can help.
Thanks!
Markus
PS: I know, I shall ask on R mailing list :-)
More information about the grass-stats
mailing list