"g.region: command not found" using readRAST6 command

10 messages Options
Embed this post
Permalink
Tim Holland

"g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
Hello,

I'm sorry to keep making so much noise on the list for what I'm sure are basic questions.  

I am having trouble loading in a GRASS raster into R using the readRAST6 command.  

Using:
>readRAST6("rasterMap",mapset="/Users/etc/my_mapset")

I get the following error:
>Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText ==  :
  argument is of length zero
>Error in parseGRASS(cmd) : g.region not parsed
>sh: g.region: command not found

Is there something I am doing wrong here?  

Also, when I am working with spgrass6 in general, should I have my working directory set to the GRASS DBase I am using, or does that matter?  

Thank you for the help,
Tim


> sessionInfo()
R version 2.9.2 (2009-08-24)
i386-apple-darwin8.11.1

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] spgrass6_0.6-9 XML_2.6-0      rgdal_0.6-12   sp_0.9-44    

loaded via a namespace (and not attached):
[1] grid_2.9.2      lattice_0.17-25

Daniel McInerney

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
Hi Tim,
Is R running within a GRASS session?

Regards,
Daniel.

Tim Holland wrote:

> Hello,
>
> I'm sorry to keep making so much noise on the list for what I'm sure are
> basic questions.  
>
> I am having trouble loading in a GRASS raster into R using the readRAST6
> command.  
>
> Using:
>  
>> readRAST6("rasterMap",mapset="/Users/etc/my_mapset")
>>    
>
> I get the following error:
>  
>> Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText ==
>>    
> :
>   argument is of length zero
>  
>> Error in parseGRASS(cmd) : g.region not parsed
>> sh: g.region: command not found
>>    
>
> Is there something I am doing wrong here?  
>
> Also, when I am working with spgrass6 in general, should I have my working
> directory set to the GRASS DBase I am using, or does that matter?  
>
> Thank you for the help,
> Tim
>
>
>  
>> sessionInfo()
>>    
> R version 2.9.2 (2009-08-24)
> i386-apple-darwin8.11.1
>
> locale:
> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base    
>
> other attached packages:
> [1] spgrass6_0.6-9 XML_2.6-0      rgdal_0.6-12   sp_0.9-44    
>
> loaded via a namespace (and not attached):
> [1] grid_2.9.2      lattice_0.17-25
>
>
>  

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

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
Hi Daniel,

No, as it was I was trying to run things through R.  Grass was (is) running, but just incidentally.  Your comment made me think I needed to run initGRASS() first, so I tried, but got the following:

> initGRASS(gisBase="/Library/GRASS/6.4", gisDbase="/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase")
Error in initGRASS(gisBase = "/Library/GRASS/6.4", gisDbase = "/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase") :
  A GISRC file already exists; to override, set override=TRUE

Should I be running R through GRASS?  (as opposed to vice-versa, as had been my understanding).  If so, how do I do that? 

Again, sorry for really basic questions, but thank you for the help.

Best,
Tim



On Wed, Oct 7, 2009 at 3:52 PM, Daniel McInerney <[hidden email]> wrote:
Hi Tim,
Is R running within a GRASS session?

Regards,
Daniel.

Tim Holland wrote:
Hello,
I'm sorry to keep making so much noise on the list for what I'm sure are
basic questions.  
I am having trouble loading in a GRASS raster into R using the readRAST6
command.  
Using:  
readRAST6("rasterMap",mapset="/Users/etc/my_mapset")
   

I get the following error:
 
Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText ==    
:  argument is of length zero
 
Error in parseGRASS(cmd) : g.region not parsed
sh: g.region: command not found
   

Is there something I am doing wrong here?  
Also, when I am working with spgrass6 in general, should I have my working
directory set to the GRASS DBase I am using, or does that matter?  
Thank you for the help, Tim


 
sessionInfo()
   
R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1
locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    
other attached packages:
[1] spgrass6_0.6-9 XML_2.6-0      rgdal_0.6-12   sp_0.9-44    
loaded via a namespace (and not attached):
[1] grid_2.9.2      lattice_0.17-25


 



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

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
Hi Tim,
You should run R from within the GRASS shell
environment.  So launch a terminal and run GRASS,
select a GRASS location and mapset, and then from
within the GRASS shell, run R. You should then be able
to read/write GRASS rasters from R.

Regards,
Daniel.

Tim Holland wrote:

> Hi Daniel,
>
> No, as it was I was trying to run things through R.  Grass was (is)
> running, but just incidentally.  Your comment made me think I needed
> to run initGRASS() first, so I tried, but got the following:
>
> > initGRASS(gisBase="/Library/GRASS/6.4",
> gisDbase="/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase")
> Error in initGRASS(gisBase = "/Library/GRASS/6.4", gisDbase =
> "/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase") :
>   A GISRC file already exists; to override, set override=TRUE
>
> Should I be running R through GRASS?  (as opposed to vice-versa, as
> had been my understanding).  If so, how do I do that?
>
> Again, sorry for really basic questions, but thank you for the help.
>
> Best,
> Tim
>
>
>
> On Wed, Oct 7, 2009 at 3:52 PM, Daniel McInerney
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi Tim,
>     Is R running within a GRASS session?
>
>     Regards,
>     Daniel.
>
>     Tim Holland wrote:
>
>         Hello,
>         I'm sorry to keep making so much noise on the list for what
>         I'm sure are
>         basic questions.  
>         I am having trouble loading in a GRASS raster into R using the
>         readRAST6
>         command.  
>         Using:  
>
>             readRAST6("rasterMap",mapset="/Users/etc/my_mapset")
>                
>
>
>         I get the following error:
>          
>
>             Error in if (file.exists(file) == FALSE) if
>             (!missing(asText) && asText ==    
>
>         :  argument is of length zero
>          
>
>             Error in parseGRASS(cmd) : g.region not parsed
>             sh: g.region: command not found
>                
>
>
>         Is there something I am doing wrong here?  
>         Also, when I am working with spgrass6 in general, should I
>         have my working
>         directory set to the GRASS DBase I am using, or does that
>         matter?  
>         Thank you for the help, Tim
>
>
>          
>
>             sessionInfo()
>                
>
>         R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1
>         locale:
>         en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
>         attached base packages:
>         [1] stats     graphics  grDevices utils     datasets  methods
>           base    
>         other attached packages:
>         [1] spgrass6_0.6-9 XML_2.6-0      rgdal_0.6-12   sp_0.9-44    
>         loaded via a namespace (and not attached):
>         [1] grid_2.9.2      lattice_0.17-25
>
>
>          
>
>
>

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

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
In reply to this post by Tim Holland
On Wed, 7 Oct 2009, Tim Holland wrote:

> Hi Daniel,
>
> No, as it was I was trying to run things through R.  Grass was (is) running,
> but just incidentally.  Your comment made me think I needed to run
> initGRASS() first, so I tried, but got the following:
>
>> initGRASS(gisBase="/Library/GRASS/6.4",
> gisDbase="/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase")
> Error in initGRASS(gisBase = "/Library/GRASS/6.4", gisDbase =
> "/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase") :
>  A GISRC file already exists; to override, set override=TRUE
>
> Should I be running R through GRASS?  (as opposed to vice-versa, as had been
> my understanding).  If so, how do I do that?

Whether you run spgrass6 freestanding or within a running GRASS depends on
what you want to do. If you only need to use GRASS analytical modules
(programs) on data that are "on the R side", the freestanding possibility
may be sufficient, as initGRASS() essentially sets up the GRASS
environment variables for you and creates a throw-away location in a
temporary directory. Then you can use write*6() to populate it, and work
from there, probably bringing the results back with read*6().

If on the other hand you have (or ought to have) a GRASS location and wish
to analyse the data in R (other way round), you start R within a running
GRASS shell, so that it inherits the environment variables and existing
location.

Beware of the GRASS/GDAL plugin - if you get odd things happening with
readRAST6(), use the plugin=FALSE argument, as this will read your data
using a temporary file instead. If you are not using the plugin, setting
the mapset should not be needed. In addition, your mapset path looks
highly non-standard - mapsets are typically within the GISDBASE and
LOCATION in a hierarchy.

When you get non-obvious error messages, please do include the output of
traceback() run immediately after the error. This permits the
identification of where in the call tree (sequence of functions called by
the function you used) the problem arose. The output of sessionInfo() is
also potentially useful.

Hope this clarifies a little.

Roger

>
> Again, sorry for really basic questions, but thank you for the help.
>
> Best,
> Tim
>
>
>
> On Wed, Oct 7, 2009 at 3:52 PM, Daniel McInerney <[hidden email]>wrote:
>
>> Hi Tim,
>> Is R running within a GRASS session?
>>
>> Regards,
>> Daniel.
>>
>> Tim Holland wrote:
>>
>>> Hello,
>>> I'm sorry to keep making so much noise on the list for what I'm sure are
>>> basic questions.
>>> I am having trouble loading in a GRASS raster into R using the readRAST6
>>> command.
>>> Using:
>>>
>>>> readRAST6("rasterMap",mapset="/Users/etc/my_mapset")
>>>>
>>>>
>>>
>>> I get the following error:
>>>
>>>
>>>> Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText
>>>> ==
>>>>
>>> :  argument is of length zero
>>>
>>>
>>>> Error in parseGRASS(cmd) : g.region not parsed
>>>> sh: g.region: command not found
>>>>
>>>>
>>>
>>> Is there something I am doing wrong here?
>>> Also, when I am working with spgrass6 in general, should I have my working
>>> directory set to the GRASS DBase I am using, or does that matter?
>>> Thank you for the help, Tim
>>>
>>>
>>>
>>>
>>>> sessionInfo()
>>>>
>>>>
>>> R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1
>>> locale:
>>> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>> other attached packages:
>>> [1] spgrass6_0.6-9 XML_2.6-0      rgdal_0.6-12   sp_0.9-44
>>> loaded via a namespace (and not attached):
>>> [1] grid_2.9.2      lattice_0.17-25
>>>
>>>
>>>
>>>
>>
>>
>

--
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
Agustin Lobo

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
In reply to this post by Tim Holland
Tim,

Please try this:
1. run grass,
2. start an xterm from the grass console
xterm &
3.  cd to the directory where you have your .RData file
4. Start R
5. require(spgrass6)
6. gmeta6()

If you get the same error, then I think you have the same problem I had
few weeks ago and was solved thanks to Markus Nettler. It's a grass problem
and has nothing to see with R. Actually, if at step 4 you run
g.region -p
you would get the same error.
Do the following:

1. Locate  your grass.conf file (mine is under /etc/ld.so.conf.d)
2. Change
/usr/lib/grass/lib
to
/usr/lib/grass64/lib

(check where the lib directory of your grass is, mine is under
/usr/lib/grass64)

3. run
sudo ldconfig

4. gmeta() should work now.

I tried to get the ubuntugis packagers to fix this, but apparently
nobody cares. See:
http://n2.nabble.com/Fwd-Re-R-sig-Geo-Errror-with-gmeta6-tp3610348p3610348.html

for more info.

Hope this helps.
Agus


Tim Holland wrote:

> Hi Daniel,
>
> No, as it was I was trying to run things through R.  Grass was (is)
> running, but just incidentally.  Your comment made me think I needed
> to run initGRASS() first, so I tried, but got the following:
>
> > initGRASS(gisBase="/Library/GRASS/6.4",
> gisDbase="/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase")
> Error in initGRASS(gisBase = "/Library/GRASS/6.4", gisDbase =
> "/Users/timholland/Documents/GIS/Vietnam_General/VN_GrassDbase") :
>   A GISRC file already exists; to override, set override=TRUE
>
> Should I be running R through GRASS?  (as opposed to vice-versa, as
> had been my understanding).  If so, how do I do that?
>
> Again, sorry for really basic questions, but thank you for the help.
>
> Best,
> Tim
>
>
>
> On Wed, Oct 7, 2009 at 3:52 PM, Daniel McInerney
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi Tim,
>     Is R running within a GRASS session?
>
>     Regards,
>     Daniel.
>
>     Tim Holland wrote:
>
>         Hello,
>         I'm sorry to keep making so much noise on the list for what
>         I'm sure are
>         basic questions.  
>         I am having trouble loading in a GRASS raster into R using the
>         readRAST6
>         command.  
>         Using:  
>
>             readRAST6("rasterMap",mapset="/Users/etc/my_mapset")
>                
>
>
>         I get the following error:
>          
>
>             Error in if (file.exists(file) == FALSE) if
>             (!missing(asText) && asText ==    
>
>         :  argument is of length zero
>          
>
>             Error in parseGRASS(cmd) : g.region not parsed
>             sh: g.region: command not found
>                
>
>
>         Is there something I am doing wrong here?  
>         Also, when I am working with spgrass6 in general, should I
>         have my working
>         directory set to the GRASS DBase I am using, or does that
>         matter?  
>         Thank you for the help, Tim
>
>
>          
>
>             sessionInfo()
>                
>
>         R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1
>         locale:
>         en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
>         attached base packages:
>         [1] stats     graphics  grDevices utils     datasets  methods
>           base    
>         other attached packages:
>         [1] spgrass6_0.6-9 XML_2.6-0      rgdal_0.6-12   sp_0.9-44    
>         loaded via a namespace (and not attached):
>         [1] grid_2.9.2      lattice_0.17-25
>
>
>          
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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
hamish-2

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
Agustin wrote:

> Do the following:
>
> 1. Locate  your grass.conf file (mine is under /etc/ld.so.conf.d)
> 2. Change
> /usr/lib/grass/lib
> to
> /usr/lib/grass64/lib
>
> (check where the lib directory of your grass is, mine is
> under /usr/lib/grass64)
>
> 3. run
> sudo ldconfig
>
> 4. gmeta() should work now.
>
> I tried to get the ubuntugis packagers to fix this, but apparently
> nobody cares. See:
> http://n2.nabble.com/Fwd-Re-R-sig-Geo-Errror-with-gmeta6-tp3610348p3610348.html
> for more info.


in the DebianGIS package the lib dir was renamed in 6.4.0~rc3-3 back in
late March. AFAIK UbuntuGIS often just rebuilds the Debian package for
their world.

http://packages.debian.org/changelogs/pool/main/g/grass/grass_6.4.0~rc5-3/changelog

are you using a newer version of grass than rc3?


it looks like Karmic's package has the versioned dirs:
  http://packages.ubuntu.com/karmic/i386/grass/filelist

(rc5-1 is buggy and should not ship without the patch from Debian's rc5-2!!
but that is another matter..
 https://bugs.launchpad.net/ubuntu/+source/grass/+bug/435177
)


Hamish




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

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
Dear all,

Thank you very much for the help.  In the end, my problem was more basic than Augustin's suggestion.  Starting R from within GRASS was basically all I needed to do.  Also, Roger, thank you for the 'pre-emptive' help with your comment about setting 'plugin=FALSE': sure enough, when I tried without that command, I got the following and R exited:

> x<-readRAST6("GLC2000_Landcover_SEAsia")
ERROR: Incompatible library version for module. You need to rebuild GRASS
       or untangle multiple installations.

But it worked fine with plugin=FALSE.

Best,
Tim


On Thu, Oct 8, 2009 at 9:21 AM, Hamish <[hidden email]> wrote:
Agustin wrote:
> Do the following:
>
> 1. Locate  your grass.conf file (mine is under /etc/ld.so.conf.d)
> 2. Change
> /usr/lib/grass/lib
> to
> /usr/lib/grass64/lib
>
> (check where the lib directory of your grass is, mine is
> under /usr/lib/grass64)
>
> 3. run
> sudo ldconfig
>
> 4. gmeta() should work now.
>
> I tried to get the ubuntugis packagers to fix this, but apparently
> nobody cares. See:
> http://n2.nabble.com/Fwd-Re-R-sig-Geo-Errror-with-gmeta6-tp3610348p3610348.html
> for more info.


in the DebianGIS package the lib dir was renamed in 6.4.0~rc3-3 back in
late March. AFAIK UbuntuGIS often just rebuilds the Debian package for
their world.

http://packages.debian.org/changelogs/pool/main/g/grass/grass_6.4.0~rc5-3/changelog

are you using a newer version of grass than rc3?


it looks like Karmic's package has the versioned dirs:
 http://packages.ubuntu.com/karmic/i386/grass/filelist

(rc5-1 is buggy and should not ship without the patch from Debian's rc5-2!!
but that is another matter..
 https://bugs.launchpad.net/ubuntu/+source/grass/+bug/435177
)


Hamish






_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Markus Neteler-2

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
Tim Holland wrote:

> Dear all,
>
> Thank you very much for the help.  In the end, my problem was more
> basic than Augustin's suggestion.  Starting R from within GRASS was
> basically all I needed to do.  Also, Roger, thank you for the
> 'pre-emptive' help with your comment about setting 'plugin=FALSE':
> sure enough, when I tried without that command, I got the following
> and R exited:
>
> > x<-readRAST6("GLC2000_Landcover_SEAsia")
> ERROR: Incompatible library version for module. You need to rebuild GRASS
>        or untangle multiple installations.
>
> But it worked fine with plugin=FALSE.

AFAIK this indicates in this case that the GRASS-GDAL plugin is out of sync
with GRASS. Rebuilding the plugin should help.

Background:
- first compile GDAL without GRASS support
- then compile GRASS (needs GDAL)
- then compile the GRASS-GDAL plugin (needs GDAL and GRASS)
- use R

Hope this helps,
Markus

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

Re: "g.region: command not found" using readRAST6 command

Reply Threaded More More options
Print post
Permalink
On Fri, 9 Oct 2009, Markus Neteler wrote:

> Tim Holland wrote:
>> Dear all,
>>
>> Thank you very much for the help.  In the end, my problem was more
>> basic than Augustin's suggestion.  Starting R from within GRASS was
>> basically all I needed to do.  Also, Roger, thank you for the
>> 'pre-emptive' help with your comment about setting 'plugin=FALSE':
>> sure enough, when I tried without that command, I got the following
>> and R exited:
>>
>>> x<-readRAST6("GLC2000_Landcover_SEAsia")
>> ERROR: Incompatible library version for module. You need to rebuild GRASS
>>        or untangle multiple installations.
>>
>> But it worked fine with plugin=FALSE.
>
> AFAIK this indicates in this case that the GRASS-GDAL plugin is out of sync
> with GRASS. Rebuilding the plugin should help.
>
> Background:
> - first compile GDAL without GRASS support
> - then compile GRASS (needs GDAL)
> - then compile the GRASS-GDAL plugin (needs GDAL and GRASS)
> - use R

Markus,

The plugin is great for those who build from source, but here Tim is using
the Kyngchaos OSX binaries, and seems to have a working system. It may be
that some plugin directory is hanging around from a failed install, but
for relatively many otherwise able users, this is too hard to fix. We've
seen numerous Debian/Ubuntu users with similar version mismatches, and
they aren't easy to settle - I get tripped up by the plugin myself when
updating GDAL or GRASS. So for people who find that it helps, not using
the plugin provides a solution avoiding building from source.

Best wishes,

Roger

>
> Hope this helps,
> Markus
>
> _______________________________________________
> 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