[STATSGRASS] Re: R-GRASS error in region changes

Roger Bivand Roger.Bivand at nhh.no
Mon Feb 21 07:02:24 EST 2005


On Mon, 21 Feb 2005, javier garcia - CEBAS wrote:

> Hi all;
> I guess that Roger B. is the best person to answer this, anyway I send the 
> question to everybody in the list (I think it is interesting):
> I'm trying to do an R script to do a statistical analysis over GRASS maps, 
> and I obtain an error. Perhaps the link R-GRASS doesn't allow to do what I'm 
> trying?
> 
> Through my R script I'm changing the region in GRASS, and after this I get 
> some maps from GRASS into R, what gives an error:
> 
> -----------------
> # R script
> library(GRASS)
> for (i in 33:1) {
>   g.region <- paste("g.region n=9.9 s=0 e=3.3 w=0 res=",3.3/i,sep="")
>   system(g.region)
>   system(paste("r.mapcalc template",i,"=1",sep=""))
>   rm(G)
>   G <- gmeta()
>   RGRASS <- rast.get(G, rlist=paste("template",i,sep=""), catlabels=FALSE)
> }
> -----------------
> 
> The R error message appears in the second loop:
> Error in rast.get(G, rlist = paste("template", i, sep = ""), catlabels = 
> FALSE) :
>         Current GRASS region changed: ns_res
> 
> 
> Could be any possibility to succeed with this?

There usually is, one way or another. But to find out, it would be useful 
to state your platform (OS, etc), which GRASS version you are using, which 
R version, and which R-GRASS interface version - that is, the usual 
routine on R-help. Knowing the versions makes it easier to see what is 
going on. If you can also replicate this on Spearfish or another very 
standard data set makes it even easier! If anyone else has insights, 
please join in!

Best wishes,

Roger 

> 
> Thanks and best regards,
> 
> Javier
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no





More information about the grass-stats mailing list