[R-sig-Geo] r.mapcalc with spgrass6

Roger Bivand Roger.Bivand at nhh.no
Tue Jul 6 23:42:56 CEST 2010


On Tue, 6 Jul 2010, Pinaud David wrote:

> Dear all,
>
> I'm trying to use the GRASS function "r.mapcalc" using R package "spgrass6", 
> but I've got some trouble with it, I'm not even able to parse this function:
>
>> library(rgdal)
> Le chargement a nécessité le package : sp
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.7.1, released 2010/02/08
> Path to GDAL shared files: C:/PROGRA~1/R/R-211~1.1/library/rgdal/gdal
> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
> Path to PROJ.4 shared files: C:/PROGRA~1/R/R-211~1.1/library/rgdal/proj
>
>> library(spgrass6)
> Le chargement a nécessité le package : XML
> GRASS GIS interface loaded with GRASS version: (GRASS not running)
>
>> parseGRASS("r.mapcalc")
> Error : syntax error, unexpected '-', expecting NAME or STRING
> Parse error  does not seem to be XML, nor to identify a file name
> Erreur dans parseGRASS("r.mapcalc") : r.mapcalc not parsed

You cannot use r.mapcalc with execGRASS for obvious reasons - r.mapcalc 
wants to handle input itself. Use r.mapcalculator instead for scripting. 
or use r.mapcalcs directly.

Hope this helps,

Roger

>
> I tried to change the XML encoding by
>> setXMLencoding("latin1")
> without success.
>
> For example,
>> parseGRASS("g.region")
> is correctly running, I've got the description of the function.
>
> Otherwise, my calculus with "r.mapcalc" within GRASS 6.4.0 is correctly 
> running.
>
>> sessionInfo()
> R version 2.11.1 (2010-05-31)
> i386-pc-mingw32
>
> locale:
> [1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252 
> LC_MONETARY=French_France.1252
> [4] LC_NUMERIC=C                   LC_TIME=French_France.1252 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base 
> other attached packages:
> [1] spgrass6_0.6-16 XML_3.1-0       rgdal_0.6-27    sp_0.9-65 
> loaded via a namespace (and not attached):
> [1] grid_2.11.1    lattice_0.18-8 tools_2.11.1 
>> get("SYS", envir = .GRASS_CACHE)
> [1] "WinNat"
>
>
> Am I missing something? Any idea?
>
> Thank you very much for your help and patience.
>
> David
>
>
>

-- 
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: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list