[R-sig-Geo] Cannot use spgrass6 under windows7
Roger Bivand
Roger.Bivand at nhh.no
Mon Jul 18 20:14:40 CEST 2011
On Mon, 18 Jul 2011, CRISTINA ARJONA wrote:
> Please disregard my previous message, I included wrong details.
> This is what I actually do and cannot get GRASS commands to work from R
> under Windows7. I try both from R with no GRASS session running and starting
> R from within the GRASS shell console:
If you are using an existing location, always start GRASS first then start
R within GRASS. This was covered in a thread on this list recently -
initGRASS() is only for use with throwaway locations created to access
GRASS functionality for R data:
https://stat.ethz.ch/pipermail/r-sig-geo/2011-May/011671.html
Roger
PS: in Windows, GRASS executables are called with the exe extension, so
use execGRASS("g.region", flags="p", intern=TRUE) to provide the
system-dependent treatment required, not as below.
>
> If I start R outside GRASS (and with GRASS not running):
>> setwd("D:/1_MASTER_SIG/1-0_PROJECTE/CALCULS")
>> require(rgdal)
> Loading required package: rgdal
> Loading required package: sp
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23
> Path to GDAL shared files: C:/Program Files/R/R-2.13.0/library/rgdal/gdal
> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
> Path to PROJ.4 shared files: C:/Program Files/R/R-2.13.0/library/rgdal/proj
>> require(raster)
> Loading required package: raster
> raster version 1.8-39 (3-July-2011)
> Warning message:
> package 'raster' was built under R version 2.13.1
>> require(spgrass6)
> Loading required package: spgrass6
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: (GRASS not running)
> Warning message:
> package 'spgrass6' was built under R version 2.13.1
>> gmeta6() #ara treballem des de r amb grass
> Error in system(cmd0, intern = TRUE) : 'g.region.exe' not found
> Error in parseGRASS(cmd) : g.region not found
>> initGRASS(gisBase= "C:/Program Files (x86)/Quantum GIS
> Wroclaw/apps/grass/grass-6.4.1/bin", home=tempdir(),
> gisDbase="D:/GRASSDATA", location= "MNSY2", mapset="MNSYGRASS", override =
> F, use_g.dirseps.exe = FALSE)
> Error in system(cmd0, intern = TRUE) : 'g.region.exe' not found
> In addition: Warning messages:
> 1: In dir.create(gisDbase) : 'D:\GRASSDATA' already exists
> 2: In dir.create(gisDbase) :
> cannot create dir 'D:\GRASSDATA', reason 'No error'
> 3: In dir.create(loc_path) : 'D:\GRASSDATA\MNSY2' already exists
> 4: In dir.create(loc_path) :
> cannot create dir 'D:\GRASSDATA\MNSY2', reason 'No error'
> Error in parseGRASS(cmd) : g.region not found
>
> If I start R from within the GRASS console (through the QGIS grass plugin):
> (having navigated to my R working directory and started up R with
> "C:\Program Files\R\R-2.13.0\bin\i386\Rgui.exe" ):
> My R workspace is loaded normally,
> Then I do:
>> require(rgdal)
> Loading required package: rgdal
> Loading required package: sp
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23
> Path to GDAL shared files: C:/Program Files/R/R-2.13.0/library/rgdal/gdal
> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
> Path to PROJ.4 shared files: C:/Program Files/R/R-2.13.0/library/rgdal/proj
>> require(raster)
> Loading required package: raster
> raster version 1.8-39 (3-July-2011)
> Warning message:
> package 'raster' was built under R version 2.13.1
>> require(spgrass6)
> Loading required package: spgrass6
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: GRASS 6.4.1 (2011)
> and location: MNSY2
> Warning message:
> package 'spgrass6' was built under R version 2.13.1
>> gmeta6()
> gisdbase D:/GRASSDATA
> location MNSY2
> mapset MNSYGRASS
> rows 549
> columns 1000
> north 4636820
> south 4613150
> west 429462
> east 472499
> nsres 43.11475
> ewres 43.037
> projection +proj=utm +no_defs +zone=31 +a=6378388 +rf=297
> +towgs84=-87,-98,-121,0,0,0,0 +to_meter=1
>>
>
> which is correct. But then, when I try to run any GRASS command, I get an
> error:
>> system("g.region -p",intern=T)
> Error in system("g.region -p", intern = T) : 'g.region' not found
>
> I've tried with initGRASS(), but
>> initGRASS(gisBase= "C:/Program Files (x86)/Quantum GIS
> Wroclaw/apps/grass/grass-6.4.1/bin", home=tempdir(),
> gisDbase="D:/GRASSDATA", location= "MNSY2", mapset="MNSYGRASS", override =
> F, use_g.dirseps.exe = FALSE)
> Error in initGRASS(gisBase = "C:/Program Files (x86)/Quantum GIS
> Wroclaw/apps/grass/grass-6.4.1/bin", :
> A GRASS location is already in use; to override, set override=TRUE
>
> Any help on what am I doing wrong? Do I have to start R from within GRASS
> under linux?
>
> Thanks!
>
> Cristina,
>> sessionInfo()
> R version 2.13.0 (2011-04-13)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
> LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
> LC_TIME=Spanish_Spain.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] spgrass6_0.6-27 XML_3.4-0.2 raster_1.8-39 rgdal_0.6-33
> sp_0.9-81
>
> loaded via a namespace (and not attached):
> [1] grid_2.13.0 lattice_0.19-23
>>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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