R packages and GRASS

4 messages Options
Embed this post
Permalink
Felipe Carrillo

R packages and GRASS

Reply Threaded More More options
Print post
Permalink
Hi all:
I'm brand new to GRASS and this list and just wanted to see if someone could point out to what I need to synchronize R and GRASS. I already downloaded GRASS 6.3, spgrass6 and dependencies and at my first attempt something is happening but I can't quite see a way to import data into R or run commands from R. I ran into the code below yesterday but I can't figure out how to run it from R.
I tried: system("g.region rast=elevation.dem") but I get an error message. Thanks
# set region:
g.region rast=elevation.dem

# extract some random points from an elevation dataset
v.random out=rs n=300

# create attribute table:
v.db.addtable map=rs columns="elev double"

# extract raster data at points
v.what.rast vect=rs rast=elevation.dem column=elev

# simple display:
d.rast elevation.dem
d.vect rs size=4

# start R
R


Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA


     
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Agustin Lobo

Re: R packages and GRASS

Reply Threaded More More options
Print post
Permalink
which error? we don't see it. Note you must start R from within
the grass console. Actually it's better if, from the grass console,
you launch xterm & and can start R from the new terminal.

Agus

Felipe Carrillo wrote:

> Hi all:
> I'm brand new to GRASS and this list and just wanted to see if someone could point out to what I need to synchronize R and GRASS. I already downloaded GRASS 6.3, spgrass6 and dependencies and at my first attempt something is happening but I can't quite see a way to import data into R or run commands from R. I ran into the code below yesterday but I can't figure out how to run it from R.
> I tried: system("g.region rast=elevation.dem") but I get an error message. Thanks
> # set region:
> g.region rast=elevation.dem
>
> # extract some random points from an elevation dataset
> v.random out=rs n=300
>
> # create attribute table:
> v.db.addtable map=rs columns="elev double"
>
> # extract raster data at points
> v.what.rast vect=rs rast=elevation.dem column=elev
>
> # simple display:
> d.rast elevation.dem
> d.vect rs size=4
>
> # start R
> R
>
>
> Felipe D. Carrillo  
> Supervisory Fishery Biologist  
> Department of the Interior  
> US Fish & Wildlife Service  
> California, USA
>
>
>      
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>
>  

[alobolistas.vcf]

begin:vcard
fn:Agustin Lobo
n:Lobo;Agustin
org:Institut de Ciencies de la Terra "Jaume Almera" CSIC
adr:;;Lluis Sole Sabris s/n;Barcelona;;08028;Spain
email;internet:[hidden email]
url:http://www.ija.csic.es/gt/obster
version:2.1
end:vcard



_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Felipe Carrillo

Re: R packages and GRASS

Reply Threaded More More options
Print post
Permalink
Agustin:
I get the message below while trying to execute from R
> system("g.region rast=elevation.dem")
Warning message:
In system("g.region rast=elevation.dem") : g.region not found

On the same note, Would you mind sending me the attachment on a different format? This is a government computer and I don't have outlook to open it. Just copy and paste onto notepad or word if you don't mind. Thanks


Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA


--- On Thu, 11/5/09, Agustin Lobo <[hidden email]> wrote:

> From: Agustin Lobo <[hidden email]>
> Subject: Re: [GRASS-stats] R packages and GRASS
> To: "Felipe Carrillo" <[hidden email]>
> Cc: "GRASS STATS" <[hidden email]>
> Date: Thursday, November 5, 2009, 8:04 AM
> which error? we don't see it. Note
> you must start R from within
> the grass console. Actually it's better if, from the grass
> console,
> you launch xterm & and can start R from the new
> terminal.
>
> Agus
>
> Felipe Carrillo wrote:
> > Hi all:
> > I'm brand new to GRASS and this list and just wanted
> to see if someone could point out to what I need to
> synchronize R and GRASS. I already downloaded GRASS 6.3,
> spgrass6 and dependencies and at my first attempt something
> is happening but I can't quite see a way to import data into
> R or run commands from R. I ran into the code below
> yesterday but I can't figure out how to run it from R. I
> tried: system("g.region rast=elevation.dem") but I get an
> error message. Thanks
> > # set region:
> > g.region rast=elevation.dem
> >
> > # extract some random points from an elevation
> dataset
> > v.random out=rs n=300
> >
> > # create attribute table:
> > v.db.addtable map=rs columns="elev double"
> >
> > # extract raster data at points
> > v.what.rast vect=rs rast=elevation.dem column=elev
> >
> > # simple display:
> > d.rast elevation.dem
> > d.vect rs size=4
> >
> > # start R
> > R
> >
> >
> > Felipe D. Carrillo  Supervisory Fishery
> Biologist  Department of the Interior  US Fish
> & Wildlife Service  California, USA
> >
> >
> >   
>    _______________________________________________
> > grass-stats mailing list
> > [hidden email]
> > http://lists.osgeo.org/mailman/listinfo/grass-stats
> >
> >   
>
>



_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand

Re: R packages and GRASS

Reply Threaded More More options
Print post
Permalink
In reply to this post by Felipe Carrillo
On Thu, 5 Nov 2009, Felipe Carrillo wrote:

> Hi all: I'm brand new to GRASS and this list and just wanted to see if
> someone could point out to what I need to synchronize R and GRASS. I
> already downloaded GRASS 6.3, spgrass6 and dependencies and at my first
> attempt something is happening but I can't quite see a way to import
> data into R or run commands from R. I ran into the code below yesterday
> but I can't figure out how to run it from R.

I replied offlist to a mail directly to me suggesting to Felipe that he
post (done), that he read the PDFs shipped with spgrass6 (he hasn't), and
to decide which mode he needs - R within GRASS or R freestanding using
GRASS in a temporary location (hasn't done that either), then read the
help pages (unknown).

system.file("doc", package="spgrass6")

shows where the PDFs live in an installed package.

He could also watch:

http://spatial.nhh.no/wun09/wun_grass.swf

which shows the use of the interface in a GRASS 6.3 Windows setting, but
before the important update to replace the direct use of system() with
execGRASS() at the user level.

I think that until these recommendations are followed, he's unlikely to
gain from any further advice. I don't have time to handhold. He has only
said that he is using GRASS 6.3, but not his system, or R's sessionInfo().

Roger

> I tried: system("g.region rast=elevation.dem") but I get an error
> message. Thanks
> # set region:
> g.region rast=elevation.dem
>
> # extract some random points from an elevation dataset
> v.random out=rs n=300
>
> # create attribute table:
> v.db.addtable map=rs columns="elev double"
>
> # extract raster data at points
> v.what.rast vect=rs rast=elevation.dem column=elev
>
> # simple display:
> d.rast elevation.dem
> d.vect rs size=4
>
> # start R
> R
>
>
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, USA
>
>
>
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>

--
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: [hidden email]

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway