[STATSGRASS] R-GRASS link problem

Roger Bivand Roger.Bivand at nhh.no
Wed Aug 8 10:24:58 EDT 2007


On Wed, 8 Aug 2007, javier garcia-pintado wrote:

> Hi;
> I've already reported this problem to the R list, but it is probable
> that the source of the problem is GRASS (5.4) instead of R.

You wrote to R-help, not to R-sig-geo, which is the correct list on the R 
side.

> I'm using the library GRASS in R to carry out a sequence of operation in
> a set of GRASS maps.
> After a couple of loops I obtain the warning message:
> "Too many open raster files"
> and the communication between R and GRASS does not work anymore for that
> moment on.
>
> The fact is that I'm opening a sequence of maps, but the destination
> name in R is always the same, so it does not seem to be an R problem but
> a GRASS one.
>

The GRASS package for legacy GRASS 5 has its own copy of the GRASS library 
files that it calls, and the problem occurs when the number of "open" 
files exceeds MAXFILES 256. You can change this in src/include/G.h and 
re-build if you like, but since the C source of rastget shows you, it is 
careful to close the file handles, line 214 in src/rastget.c. This leads 
me to think that this is an OS story, and so we need to know your OS. 
Here, Windows or cygwin may behave very differently when freeing system 
resources from say Linux.

For me on Linux, running example(rast.get) outside GRASS (I do not have a 
working GRASS 5 installation any more) and then running:

for (i in 1:260) {
  print(i)
  exget <- rast.get(G, rlist=c("ex.Zn.grid.in", "ex.tr3.in",
   "ex.Zn.grid.o.in"), catlabels=as.logical(c(FALSE, FALSE, TRUE)))
}

did not show any problems.

Roger

> Could you advise me about how to solve this?
>
> Thanks and best regards,
>
> Javier
> ------------------------
>
>

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




More information about the grass-stats mailing list