[STATSGRASS] Using GRASS/R interface with an xy location &

Steven Stoddard sstoddar at uiuc.edu
Tue Feb 8 13:21:30 EST 2005


Ok, the issues all seem to derive from the region settings created by 
GRASS 5.7.  In order to work in this location with GRASS 5.4, I had to 
modify the DEFAULT_WIND  file.  Just had to remove the extra lines 5.7 
uses to get the following:

GRASS 5.4.0 > cat DEFAULT_WIND
proj:       0
zone:       0
north:      100
south:      0
east:       100
west:       0
cols:       100
rows:       100
e-w resol:  1
n-s resol:  1


After modifying DEFAULT_WIND, I could connect GRASS 5.7 and R without 
any problems.  I don't know (yet!) if changing the default region 
settings will have any implications for working in GRASS 5.7.

FYI -- I attached a 5.7/R session prior to modifying DEFAULT_WIND, 
including the 'reverse(G)' error (below).  Maybe it will be of use for 
updating the GRASS/R interface.

 > library(GRASS)
GRASS environment variables in: /tmp/grass6-steve-3644/gisrc
 > G<-gmeta()
Error in gmeta() : region for current mapset is invalid
line 11: <top:        100>
run "g.region"

 > G<-gmeta(interp=TRUE)
 > summary(G)
Data from GRASS 5.0 LOCATION NL1 with 100 columns and 100 rows;
projection: 0 (x,y); zone:       0
The west-east range is: 0, 100,
and the south-north: 0, 100;
West-east cell sizes are 1 units,
and south-north 1 units.

 > rb1<-rast.get(G, rlist=c("rb1"),interp=T)
 > plot(G, rb1$rb1)
Error in reverse(G) : cannot allocate vector of length 1086556160


---
Steven T. Stoddard

Program in Ecology, Evolution and Conservation Biology
University of Illinois at Urbana-Champaign

(217) 333-2235
302 Shelford Vivarium
606 E. Healy Ave
Champaign, IL  61820
http://www.life.uiuc.edu/~sstoddar


On Feb 8, 2005, at 11:18 AM, Roger Bivand wrote:

> On Tue, 8 Feb 2005, Steven T.Stoddard wrote:
>
>> Ok.  The work-around I can grow accustomed to, or I might fall back on
>> GRASS5.4 if that works.
>>
>> I wonder if another problem that cropped up is somehow related to the
>> first.  Using interp=TRUE I managed to import a raster map to R.  But
>> when trying to plot it, I get the following:
>>
>>> plot(G,tt$rb1)
>> Error in reverse(G) : cannot allocate vector of length 1086556160
>
> What does summary(G) say? It sounds as though the numbers of rows 
> and/or
> columns have the wrong values.
>
> Over 1G cells is a bit extreme?
>
> Roger
>
>>
>> ???
>>
>> Thanks for the help,
>> Steve
>>
>>
>> ---
>> Steven T. Stoddard
>>
>> Program in Ecology, Evolution and Conservation Biology
>> University of Illinois at Urbana-Champaign
>>
>> (217) 333-2235
>> 302 Shelford Vivarium
>> 606 E. Healy Ave
>> Champaign, IL  61820
>> http://www.life.uiuc.edu/~sstoddar
>>
>>
>> On Feb 8, 2005, at 10:58 AM, Roger Bivand wrote:
>>
>>> On Tue, 8 Feb 2005, Steven T.Stoddard wrote:
>>>
>>>> I am using GRASS 5.7 and R 2.0 for OS X.  I have a simple xy 
>>>> location
>>>> I
>>>> am doing some theoretical work with and would like to import maps 
>>>> into
>>>> R using the interface in order to do analyses.  Yet when I attempt 
>>>> to
>>>> do this, I get the following error:
>>>>
>>>>> G<-gmeta()
>>>> Error in gmeta() : region for current mapset is invalid
>>>> line 11: <top:        100>
>>>> run "g.region"
>>>>
>>>> I traced the problem to the compiled C program that is called from 
>>>> the
>>>> gmeta R function (i.e. > .C("gmeta") gives me the same error). I
>>>> haven't been able to locate the source code on my volume.
>>>>
>>>> If I use gmeta(interp = TRUE) there is no problem, until I want to
>>>> actually try and import data from my locations.
>>>
>>> The current fix for 5.7 and 6.0.0beta is to use interp=TRUE. The 
>>> cause
>>> of
>>> the problem seems to be the use of the 3D WINDOW, which the older 
>>> code
>>> in
>>> the R-GRASS interface doesn't yet honour. I'm not at all sure what 
>>> will
>>> happen if your x,y locations are sites; the interface knows about
>>> old-style sites, not vector sites. You may be obliged to use
>>> system("") to
>>> issue GRASS 5.7 commands to write out an ASCII file to read into R 
>>> with
>>> read.table().
>>>
>>> Roger
>>>
>>>
>>>>
>>>> Any help is appreciated.
>>>>
>>>> Steve
>>>>
>>>> ---
>>>> Steven T. Stoddard
>>>>
>>>> Program in Ecology, Evolution and Conservation Biology
>>>> University of Illinois at Urbana-Champaign
>>>>
>>>> (217) 333-2235
>>>> 302 Shelford Vivarium
>>>> 606 E. Healy Ave
>>>> Champaign, IL  61820
>>>> http://www.life.uiuc.edu/~sstoddar
>>>>
>>>>
>>>
>>> -- 
>>> 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
>>>
>>>
>>
>
> -- 
> 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
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 4827 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-stats/attachments/20050208/0d4813c5/attachment.bin


More information about the grass-stats mailing list