Skip to content

spgrass6: execGRASS: make the output of the command an R object.

6 messages · Paulo van Breugel, Roger Bivand, Rainer M Krug

#
On Mon, 20 May 2013, Paulo van Breugel wrote:

            
With GRASS 6.4.2:

a <- execGRASS("r.univar", flags = "g", map = "elevation.dem", intern = 
TRUE)

works as before. Adding the fs= parameter causes the failure. You are 
using GRASS 7, in which fs= is separator=. In:

raster/r.univar/r.univar_main.c

only \\t, tab, space, and comma are defined as such, others seem to be 
accepted, but ";" is not. I think that the parameter is unused anyway in 
script-style output, but setting fs=";" certainly causes trouble.

Try without that parameter. Your observed difference in behaviour is not 
intended from the R side, and is caused by odd behaviour and interaction 
between parameters on the GRASS side in this GRASS module for your 
parameter settings. Other GRASS modules, and r.univar with different fs= 
settings, work as expected on Unix platforms, but under Windows, legacy 
execution is enforced anyway.

Hope this clarifies,

Roger

  
    
#
On Mon, 20 May 2013, Paulo van Breugel wrote:

            
With GRASS 7:

a <- execGRASS("r.univar", flags = "t", map = "elevation.dem",
  separator="; ", intern = TRUE)

works, but:

a <- execGRASS("r.univar", flags = "t", map = "elevation.dem",
   separator=";", intern = TRUE)

does not. The problem is that the trailing ";" on the command line to 
GRASS is also the shell line terminator, so must be protected by quoting:

a <- execGRASS("r.univar", flags = "t", map = "elevation.dem",
   separator="';'", intern = TRUE)

or:

a <- execGRASS("r.univar", flags = "t", map = "elevation.dem", 
separator=shQuote(";"), intern = TRUE)

both work.

Roger

  
    
#
Roger Bivand <Roger.Bivand at nhh.no> writes:
Following the escaping: I can not think about any problems, if all
arguments for grass are quoted (OK - I am speaking from the Linux side
without enough Windows experience with R to know if it works there as
well). Escaping *all* arguments *automatically* should make
execGRASS even more stable?

Rainer
<#secure method=pgpmime mode=sign>