Thanks for the support!Please see below my comments.

> Date: Fri, 15 Apr 2016 20:58:15 +0200
> From: roger.biv...@nhh.no
> To: baerro...@outlook.com
> CC: r-sig-geo@r-project.org
> Subject: Re: [R-sig-Geo] GISRC environment variable using initGRASS
> 
> On Fri, 15 Apr 2016, Roger B�r wrote:
> 
> > I am currently using the R package "rgrass7" (Version: 0.1-6) in order 
> > to command GRASS GIS (Windows7, OSGEO4W installation).
> >
> > I use R in order to start a GRASS environment and to script my 
> > geoprocessing. Both is working fine. However, I have problems with 
> > storing and calling the GRASS gisenv variables. Every time when I call 
> > "initGRASS" a file called "junk" is created containing GRASS gisenv 
> > variables.
> >
> 
> What the file is called is probably immaterial.
> 
> >
> > Looking at the source of the initGRASS function the section below 
> > puzzeled me somehow:
> >
> >  59   Sys.setenv(GISRC = paste(Sys.getenv("HOME"), "\\.grassrc7", 
> >  60     sep = ""))
> 
> This is setting GISRC to a value

 Yes. The absolute path to the file (containing settings for GISDBASE, 
LOCATION_NAME and MAPSET) 

> >  61   if (file.exists(Sys.getenv("GISRC")) && !override) 
> >  62     stop("A GISRC file already exists; to override, set override=TRUE")
> >  63  Sys.setenv(GISRC = "junk")
> 
> This is setting it again in the working directory - I don't recall why - 
> probably frustration years ago with Windows.

I really do not understand the "junk" (line 63). Because GISRC is set to "junk" 
the subsequent lines of code will write the GISRC environment variables to a 
newly created file called "junk" in the home folder. 
Shouldn't this line not rather be omitted? 
(The GRASS environment variables would then be written to ".grassrc7", which in 
my opinion would be correct)

> 
> >  64  cat("GISDBASE:", getwd(), "\n", file = Sys.getenv("GISRC"))
> >  65  cat("LOCATION_NAME: <UNKNOWN>", "\n", file = Sys.getenv("GISRC"), 
> >  66     append = TRUE)
> >  67  cat("MAPSET: <UNKNOWN>", "\n", file = Sys.getenv("GISRC"), 
> >  68     append = TRUE)
> >  69  gisrc <- ifelse(use_g.dirseps.exe, system(paste("g.dirseps.exe -g", 
> >  70     shQuote(Sys.getenv("GISRC"))), intern = TRUE), Sys.getenv("GISRC"))
> >  71   assign("addEXE", .addexe(), envir = .GRASS_CACHE)
> >   72  Sys.setenv(GISRC = gisrc)
> >
> 
> And this sets it again. It is set, otherwise GRASS wouldn't work; 
> programmatically you'd have to use Sys.getenv("GISRC") to get the value. 
> Please provide a use case where this matters, and consider moving this 
> thread to the statsgrass list.

Sorry, I do not understand what you mean with "provide a use case where this 
matters". What do you mean with "this"?
I added the thread to the grass-stat list (and will remove r-sig from the cc 
the next time).
Roger

> 
> Hope this helps (doesn't clarify, but that's legacy Windows),
> 
> Roger
> 
> > First, why is initGRASS using ".grassrc7" for storing the GISRC file? 
> > InitGRASS is looking for the GISRC file under ".grassrc7" (line 59). 
> > However, in the package documentation [1], the GISRC file is called 
> > ".gisrc". Moreover, the GRASS documentation says that the GISRC file is 
> > stored under "/.grass7/rc"
> >
> > Second, what is the purpose of assigning "junk" to the GISRC environment 
> > variable? 
> > GISRC is set to "junk" (line 63) and then the GISRC value ("junk") is 
> > assigned again back to system variable GISRC. Unless I misinterpreded the 
> > code, it does not make much sense to me. Shouldn't the enviroment varibales 
> > not be written (line 64 - 68) to ".grassrc7" rather than to "junk"?
> >
> >
> >
> > I would appreciate any support or hints!
> >
> > Regards,
> > Roger
> >
> > [1] http://https//cran.r-project.org/web/packages/rgrass7/rgrass7.pdf
> > [2] http://grass.osgeo.org/grass70/manuals/variables.html
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> 
> -- 
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: roger.biv...@nhh.no
> http://orcid.org/0000-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
> http://depsy.org/person/434412
                                          
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to