[R-sig-Geo] grass.script not found in R+grass7 session

Roger Bivand Roger.Bivand at nhh.no
Sat Jan 12 14:06:12 CET 2013


On Sat, 12 Jan 2013, Roger Bivand wrote:

> On Fri, 11 Jan 2013, Roger Bivand wrote:
>
>> On Fri, 11 Jan 2013, Jean-Baptiste wrote:
>> 
>>> Hi listers,
>>> 
>>> I am working on Ubuntu 12.04, R 2.15.2, GRASS 7.0. All function work fine 
>>> in
>>> a classic GRASS session.
>>> 
>>> I am trying to run GRASS interface in an R session with spgrass6 and
>>> initGRASS function. When I am used a grass function with command system(), 
>>> I
>>> am getting the following error message :
>>> "ImportError: No module named grass.script"
>>> 
>>> I checked python path from the GRASS terminal and getting the following
>>> message :
>>> /usr/local/grass-7.0.svn/etc/python
>>> 
>>> Any idea on how to fix this problem?
>> 
>> None at all, with this level of detail in your account. A simple 
>> reproducible example is needed (at least with the SVN revision number of 
>> GRASS 7, it is the development version, and moves fast). You haven't 
>> included any details of the offending R code, or of the versions of 
>> packages (output of sessionInfo()). Finally, the right list is:
>> 
>> http://lists.osgeo.org/mailman/listinfo/grass-stats
>> 
>> for this kind of detailed question.
>
> Further, after updating GRASS 7 to revision 54605, I can run:
>
> library(spgrass6)
> data(meuse)
> library(rgdal)
> coordinates(meuse) <- ~x+y
> proj4string(meuse) <- CRS("+init=epsg:28992")
> library(maptools)
> SG <- Sobj_SpatialGrid(meuse)$SG
> td <- tempdir()
> loc <- initGRASS("/home/rsb/topics/GRASS/G7svn/grass-7.0.svn", td, SG)
> loc
> writeVECT6(meuse, "meuse", v.in.ogr_flags="o")
>
> without problems. My sessionInfo() output:
>
>> sessionInfo()
> R version 2.15.2 (2012-10-26)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=C                 LC_NAME=C
> [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] grid      stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
> [1] maptools_0.8-21 lattice_0.20-13 foreign_0.8-52  rgdal_0.8-01
> [5] spgrass6_0.7-12 XML_3.95-0.1    sp_1.0-5
>
> loaded via a namespace (and not attached):
> [1] tools_2.15.2
>> execGRASS("g.version")
> GRASS 7.0.svn (2012)

But:

> parseGRASS("v.db.addcolumn")
Traceback (most recent call last):
   File 
"/home/rsb/topics/GRASS/G7svn/grass-7.0.svn/scripts/v.db.addcolumn", line 
43, in <module>
     import grass.script as grass
ImportError: No module named grass.script
Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText == 
:
   argument is of length zero
In addition: Warning message:
running command 'v.db.addcolumn --interface-description' had status 1
Error in parseGRASS("v.db.addcolumn") : v.db.addcolumn not parsed
> Sys.getenv("PYTHONPATH")
[1] ""
> Sys.getenv("GISBASE")
[1] "/home/rsb/topics/GRASS/G7svn/grass-7.0.svn"
> Sys.setenv(PYTHONPATH=paste(Sys.getenv("GISBASE"), "etc", "python", 
sep="/"))
> Sys.getenv("PYTHONPATH")
[1] "/home/rsb/topics/GRASS/G7svn/grass-7.0.svn/etc/python"
> parseGRASS("v.db.addcolumn")
Command: v.db.addcolumn
Description: Adds one or more columns to the attribute table connected to 
a given vector map.
Keywords: vector, attribute table, database
Parameters:
   name: map, type: string, required: yes, multiple: no
   keydesc: name, keydesc_count: 1
...

so changes in GRASS require a modification to initGRASS(). I've committed 
a patch to the R-forge rspatial project, module spgrass6, revision 1333. 
Please report back if you can check the revised version - try:

  install.packages("spgrass6", repos="http://R-Forge.R-project.org")

once you see 0.7-13 and revision >=1333 in the spgrass6 box on:

https://r-forge.r-project.org/R/?group_id=1014

If others could try this too, also on other platforms, I'd be grateful.

Roger


>
> Roger
>
>> 
>> Roger
>> 
>>> Thanks,
>>> 
>>> Jean-Baptiste
>>> 
>>> 
>>> 
>>> --
>>> View this message in context: 
>>> http://r-sig-geo.2731867.n2.nabble.com/grass-script-not-found-in-R-grass7-session-tp7582292.html
>>> Sent from the R-sig-geo mailing list archive at Nabble.com.
>>> 
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>> 
>> 
>> 
>
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list