[GRASSLIST:6125] Re: problems with grass6beta2 and R

Roger Bivand Roger.Bivand at nhh.no
Fri Mar 11 05:27:41 EST 2005


I have opened a sandbox for working on the R/GRASS interface for GRASS 
6 at:

http://sourceforge.net/projects/r-spatial/, module spgrass6.

I have also released spgrass6_0.1-1.tar.gz on sourceforge - so far, only 
metadata to R, and getting and putting vector point data (formerly sites) 
is present. These functions will be supplemented by raster get/put. They 
will also be integrated into the sp framework - more later.

Examples running under 6.0.0 in spearfish 57:

> library(spgrass6)
> G <- gmeta6()
> str(G)
List of 25
 $ GISDBASE     : chr "/home/rsb/topics/grassdata"
 $ LOCATION_NAME: chr "spearfish57"
 $ MAPSET       : chr "rsb"
 $ GRASS_GUI    : chr "text"
 $ projection   : chr "1 (UTM)"
 $ zone         : chr "13"
 $ datum        : chr "nad27"
 $ ellipsoid    : chr "clark66"
 $ north        : num 4928010
 $ south        : num 4913700
 $ west         : num 589980
 $ east         : num 609000
 $ top          : num 1
 $ bottom       : num 0
 $ nsres        : num 30
 $ nsres3       : num 30
 $ ewres        : num 30
 $ ewres3       : num 30
 $ tbres        : num 1
 $ rows         : int 477
 $ rows3        : int 477
 $ cols         : int 634
 $ cols3        : int 634
 $ depths       : int 1
 $ proj4        : chr "+proj=utm +zone=13 +a=6378206.4 +rf=294.9786982 
+no_defs +nadgrids=conus"
> bugs <- getSites6("bugsites")
> str(bugs)
`data.frame':   90 obs. of  4 variables:
 $ cat : int  1 2 3 4 5 6 7 8 9 10 ...
 $ x   : int  590232 590430 590529 590546 590612 590744 ...
 $ y   : int  4915039 4915204 4914625 4915353 4915320 ...
 $ str1: Factor w/ 1 level "Beetle site": 1 1 1 1 1 1 1 1 1 1 ...
> putSites6(bugs, "newbugs")
Maximum input row length: 30
Maximum number of columns: 4
Minimum number of columns: 4
column: 1  type: integer
column: 2  type: integer
column: 3  type: integer
column: 4  type: string  length: 11
Building topology ...
90 primitives registered      
Building areas:  100%
0 areas built      
0 isles built
Attaching islands: 
Attaching centroids:  100%
Topology was built.
Number of nodes     :   90
Number of primitives:   90
Number of points    :   90
Number of lines     :   0
Number of boundaries:   0
Number of centroids :   0
Number of areas     :   0
Number of isles     :   0
[1] "v.in.ascii in=/tmp/Rtmpp835dB/file74b0dc51 out=newbugs x=2 y=3 cat=1 
columns=' cat int, x int, y int, str1 varchar(11)'"
> bugs2 <- getSites6("newbugs")
> str(bugs2) 
`data.frame':   90 obs. of  4 variables:
 $ x   : int  590232 590430 590529 590546 590612  ...
 $ y   : int  4915039 4915204 4914625 4915353 4915320  ...
 $ cat : int  1 2 3 4 5 6 7 8 9 10 ...
 $ str1: Factor w/ 1 level "Beetle site": 1 1 1 1 1 1 1 1 1 1 ...
>

This code is for GRASS 6.0.0, and is written against yesterday's release. 
Please use the STATGRASS mailing list for reports, not this main list. For 
contributors, I can open developer access if needed, but code volumes are 
small, so we'll see.

Hope this relieves some of the problems caused by 5/6 incompatibilities, 
and that users will try the functions out with more taxing data than just 
bugsites.

Roger


On Mon, 7 Mar 2005, Roger Bivand wrote:

> Pete,
> 
> On Mon, 7 Mar 2005, Pete Lancashire wrote:
> 
> > Roger,
> > 
> > I found your reply in my SPAM filter that I was cleaning out
> > Sunday. The rules have been fixed.
> > 
> 
> Actually your filter seems to be quite well tuned, given my tendency to 
> muse on-list ...
> 
> > I'll dig up the example I was going to work on.
> > 
> 
> Please do - if it is as small as possible, I'll try to work with it in the 
> sandbox if that's OK (i.e. data already world-readable).
> 
> > Please don't take my comment as to being frustrated the wrong
> > way. It was not a complaint on the extensive work that has been
> > volunteered, but on communication and coordination between groups.
> > 
> Yes, but the crunch is code, not communication or coordination, isn't it?
> 
> > The sandbox is a great idea, and a tool all projects should use.
> 
> Will do.
> 
> > 
> > Again, sorry for not responding sooner
> 
> OK, I just got used to West Coast (?) locations responding before I hit 
> enter late evening in Europe.
> 
> Roger
> 
> > 
> > -pete "One ERSI and Oracle License can buy you ...." 
> > 
> > On Mon, 2005-03-07 at 00:12, Roger Bivand wrote:
> > > I'm forwarding to the list my off-list reply to Pete Lancashire, to which
> > > he has not had the courtesy to respond, in particular to my offer (at foot
> > > of message) to interact with him in trying to find a resolution to his
> > > immediate needs. The only response was to post a *bug* report on the known
> > > fact that the GRASS5.* interface to R doesn't work in compiled mode with
> > > GRASS6 - reports indicate that it seems to work in interpreted mode for 
> > > raster layers.
> > > 
> > > I will be establishing a sourceforge sandbox to publish ideas (see
> > > discussion below), and am grateful to Paolo Cavallini and Miha Staut for
> > > their ideas so far. I will post the address when ready.
> > > 
> > > Roger Bivand
> > > 
> > > ---------- Forwarded message ----------
> > > Date: Sat, 5 Mar 2005 21:46:24 +0100 (CET)
> > > From: Roger Bivand <Roger.Bivand at nhh.no>
> > > To: Pete Lancashire <list at pdxeng.com>
> > > Subject: Re: [GRASSLIST:5891] Re: problems with grass6beta2 and R
> > > 
> > > Pete:
> > > 
> > > On Sat, 5 Mar 2005, Pete Lancashire wrote:
> > > 
> > > > I just want to add a voice to this.
> > > > 
> > > > I'm trying to 'promote' the use of OSS withing a
> > > > very conservative industry and am putting together
> > > > a demo that includes Grass with PostGIS and R.
> > > > 
> > > > Doing a demo with Grass with R would have been a 90%
> > > > winner. And believe that if successful development
> > > > money could surface.
> > > > 
> > > > I would hope that in the future the Grass dev. team
> > > > take into consideration input from other projects
> > > > that are helping make Grass a valid alternative.
> > > > Saying that, I do want to add my greatest admiration
> > > > for the project so far.
> > > > 
> > > > My only recourse is to "down grade" to 5.4, but that
> > > > will then kill some of the other demo's.
> > > > 
> > > 
> > > The interface was just for rasters in 2D, and was extended to sites. The 
> > > problem that has occurred is because a very quick decision was made to 
> > > alter a fundamental file structure for 6.0, a file structure that has been 
> > > fixed essentially since GRASS began. If I change the current interface, 
> > > which works for most users, their work will be broken. 6.0 is not yet 
> > > released, and is a fast moving codebase, which is by definition hard to 
> > > interface to. 
> > > 
> > > My repeated requests to the list for advice and help from 
> > > people who actually use 6.0.0beta* has yielded a two-line script using 
> > > system() in R - which could be elaborated for handling vectorised sites, 
> > > and an offer to try out anything I happen to write. But *no* offers of 
> > > code or working examples of loose coupling (writing the GRASS vector 
> > > layer(s) to file as a shapefile or e00, reading into R, writing from R as 
> > > a file, importing into GRASS). 
> > > 
> > > We also have rgdal as the GDAL bindings for R, and it is quite possible
> > > that alpha code for OGR could get to where you need to be. But that isn't
> > > what you are putting on the table, is it? 
> > > 
> > > (At least part of the problem is that GRASS6 vector also involves using
> > > (as you include below) various databases, which R can talk to directly -
> > > so the R/GRASS interface remains just R/GRASS for raster, but potentially
> > > becomes R/(GRASS hands off a driver to) many different databases -
> > > designing for this could potentially drop GRASS and just go to the
> > > databases, or even reverse roles and embed the R engine inside GRASS or
> > > the database. I suspect that this includes so many local variants that 
> > > the vector interface will have to be loose-coupled, or tightly 
> > > customised with the database drivers; R could also be embedded elsewhere 
> > > I think, depending on the distribution of tasks and which process is "in 
> > > charge" - now R runs on top of GRASS with the user using the R 
> > > interface, but with embedding, this can be done differently - see:
> > > http://www.est.ufpr.br/myR/ for an example. See also: 
> > > http://www.math.uni-klu.ac.at/~agebhard/preDSC2003.pdf).
> > > 
> > > > -pete "A frustrated at times OSS Promoter"
> > > 
> > > Well, just imagine how frustrated volunteer overtime developers and 
> > > especially maintainers feel! You add new fun stuff and get current users 
> > > all over you very quickly!
> > > 
> > > > 
> > > > P.S. Demo would have included Grass6, R, GDAL, PostGIS,
> > > > MySQL, data exchange with Oracle 10g, PHP, Perl, Apache,
> > > > and a Beowulf Clusters.
> > > > 
> > > 
> > > Please describe in detail what needs to be passed between GRASS and R, and 
> > > how much time you can give me to try it out - you have the examples, I 
> > > don't - and I'll try and give you some pointers and R scripts. Please 
> > > also state the version of your platform and at least GRASS, GDAL, and 
> > > R. The GRASS interface (note 5.0!) began that way. If it's simple enough - 
> > > write a shapefile from GRASS, read a shapefile into R, do stuff, write 
> > > shapefile or raster (Arc ASCII GRID works anyway) or whatever with new 
> > > stuff, read into GRASS, it's doable.
> > > 
> > > Roger
> > > 
> > > > 
> > > > 
> > > > On Wed, 2005-02-23 at 10:39, Roger Bivand wrote:
> > > > > On Wed, 23 Feb 2005, Carlos Henrique Grohmann wrote:
> > > > > 
> > > > > > Hello all,
> > > > > > 
> > > > > > is there anything wrong about grass6 and R?
> > > > > 
> > > > > This has now been raised many times. The GRASS/R interface was broken by 
> > > > > the imposition of 3D windows in GRASS 6 (and sites have gone away too). It 
> > > > > is reported to work with the interp= argument set to TRUE, that is, not 
> > > > > using the compiled interface, but exchanging text files. Please note the 
> > > > > full title of the GRASS package in R: "Interface between GRASS 5.0 
> > > > > geographical information system and R" - in fact 5.4 still works as 
> > > > > designed, but 6.0 does not. 
> > > > > 
> > > > > I am open to offers of help to rectify this, and suggested doing this on
> > > > > sourceforge so that others can contribute.  Many users depend on GRASS 5
> > > > > and the interface, so the current structure must be maintained;
> > > > > development of a 6.0 version can be done, but needs contributions from
> > > > > people actually using 6.0 and willing to help replace the sites functions
> > > > > and write vector functions.
> > > > > 
> > > > > > 
> > > > > > I tried to run it today and look what I get:
> > > > > > 
> > > > > > 
> > > > > > > library(GRASS)
> > > > > > GRASS environment variables in: /tmp/grass6-guano-5178/gisrc
> > > > > > > G<-gmeta()
> > > > > > Error in gmeta() : Bad or no region for current mapset
> > > > > > >
> > > > > > 
> > > > > > I installed the R GRASS package with:
> > > > > > > R CMD INSTALL --configure-args=--grass5=/usr/local/bin/grass60
> > > > > > GRASS_0.2-23.tar.gz
> > > > > > 
> > > > > 
> > > > > The "--configure-args=--grass5=/usr/local/bin/grass60" have been 
> > > > > redundant for about three years, by the way, because the package contains 
> > > > > copies of GRASS library source files for 5.* raster and sites access, and 
> > > > > so does *not* link to binary libraries (this was a problem on cygwin at 
> > > > > the time).
> > > > > 
> > > > > Roger Bivand
> > > > > 
> > > > > 
> > > > > > any ideas?
> > > > > > 
> > > > > > thanks
> > > > > > 
> > > > > > +----------------------------------------------------------+
> > > > > >           Carlos Henrique Grohmann - Guano  
> > > > > >    Geologist M.Sc - Doctorate Student at IGc-USP - Brazil
> > > > > >         Linux User #89721  - guano at usp dot br
> > > > > > +----------------------------------------------------------+
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > 
> > > > 
> > 
> > 
> 
> 

-- 
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-user mailing list