[GRASS-user] passing output from GRASS to R.

Milton Cezar Ribeiro miltinho.astronauta at gmail.com
Mon May 4 20:28:55 EDT 2009


Hi Markus,

Under windows I needed only small changes

rasterfiles <- read.table(textConnection(system("g.mlist.exe rast
pattern=*output*", intern = TRUE)))
Thanks a lot,

milton

2009/5/4 Markus Neteler <neteler at osgeo.org>

> On Mon, May 4, 2009 at 8:57 PM, Milton Cezar Ribeiro
> <miltinho.astronauta at gmail.com> wrote:
> > Dear all,
> >
> > I am running R inside GRASS 6.4 and I can see a list
> > of all my raster files when I type (from the R session)
> >
> > system("g.list rast")
> >
> > But I would like to pass the list of rasters to a vector object in R.
> >
> > I tryed innocently this, but not worked:
> >
> > my.rast.list<-system("g.list rast")
>
> Try this:
>
> > rasterfiles <- read.table(textConnection(system("g.mlist rast",intern =
> TRUE)))
> > str(rasterfiles)
> 'data.frame':   42 obs. of  1 variable:
>  $ V1: Factor w/ 42 levels "aspect","basin_50K",..: 31 1 2 3 4 5 6 7 8 9
> ...
> > rasterfiles
>                     V1
> 1            myfacility
> 2                aspect
> 3             basin_50K
> 4  boundary_county_500m
> ...
>
> > I also would like to define a pattern of raster names to the g.list
> command,
> > like only return that raster names that have "_output_" on the name.
>
> So:
> > rasterfiles <- read.table(textConnection(system("g.mlist rast
> pattern="*_output_*",intern = TRUE)))
> > str(rasterfiles)
>
>
>
> > By the way, I am running GRASS inside MSYS, under windows.
>
> Please report if above works (as it does on Linux).
>
> Markus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20090504/daf3f588/attachment.html


More information about the grass-user mailing list