Re: [GRASS-stats] Error when starting grass from R (grass installed thru osgeo4w)

2018-09-23 Thread Helmut Kudrnovsky
>I could reproduce the problem after starting the OSGeo4W console from the
>desktop shortcut icon.
>
>The problem seems to be that OSGeo4W's console starts in a directory for
>which the user does not have write access (for me from a desktop shortcut
>C:\Users\Public\Desktop\OSGeo4W). Because rgrass7::initGRASS() needs to
>write a GISRC file in the working directory, it needs write access. When I
>changed working directory to one to which I did have write access, the
>current CRAN binary rgrass7 loaded correctly under OSGeo4W for a
>throw-away location. I haven't yet tried with a pre-existing location.
>
>Could you check and see whether this seems reasonable?
>
>If so, I'll add a check for write access in the working directory to give
>a more sensible error message.

tested here with an existing location while changed the working directory to
writable directory:

--
run o-help for a list of available commands
C:\>d:

D:\>cd temp

D:\temp>cd testR

D:\temp\testR>R

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
Tippen Sie 'license()' or 'licence()' für Details dazu.

R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
Tippen Sie 'contributors()' für mehr Information und 'citation()',
um zu erfahren, wie R oder R packages in Publikationen zitiert werden
können.

Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
Tippen Sie 'q()', um R zu verlassen.

> library(rgrass7)
Lade nötiges Paket: sp
Lade nötiges Paket: XML
GRASS GIS interface loaded with GRASS version: (GRASS not running)
> initGRASS(gisBase = "C:/OSGeo4W64/apps/grass/grass-7.4.1",
+ gisDbase = "D:/grassdata/", location = "nc_spm_08_grass7",
+ mapset = "user1", SG="elevation")
gisdbaseD:/grassdata/
locationnc_spm_08_grass7
mapset  user1
rows474
columns 526
north   228527.2
south   215018.2
west629980
east644971
nsres   28.5
ewres   28.5
projection  +proj=lcc +lat_1=36.16 +lat_2=34.34
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +to_meter=1
Warnmeldung:
In dir.create(gisDbase) : 'D:\grassdata' existiert bereits
> g <- gmeta()
> g
gisdbaseD:/grassdata/
locationnc_spm_08_grass7
mapset  user1
rows474
columns 526
north   228527.2
south   215018.2
west629980
east644971
nsres   28.5
ewres   28.5
projection  +proj=lcc +lat_1=36.16 +lat_2=34.34
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +to_meter=1
>
-

yes, the issue is that OSGeo4W's console starts in a directory for
which the user does not have write access.

changing to a directory with write access starting grass from R works as
expected.

I'll change the wiki accordingly.

>If so, I'll add a check for write access in the working directory to give
>a more sensible error message.

that would be helpful.




-
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Stats-f4049448.html
___
grass-stats mailing list
grass-stats@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-stats

Re: [GRASS-stats] Error when starting grass from R (grass installed thru osgeo4w)

2018-09-23 Thread Roger Bivand

On Wed, 19 Sep 2018, Veronica Andreo wrote:


Hello Roger,

Thanks for coming back to this thread. The course, I'll teach starts on
October 22. So, we have 4+ weeks :)


I could reproduce the problem after starting the OSGeo4W console from the 
desktop shortcut icon.


The problem seems to be that OSGeo4W's console starts in a directory for 
which the user does not have write access (for me from a desktop shortcut 
C:\Users\Public\Desktop\OSGeo4W). Because rgrass7::initGRASS() needs to 
write a GISRC file in the working directory, it needs write access. When I 
changed working directory to one to which I did have write access, the 
current CRAN binary rgrass7 loaded correctly under OSGeo4W for a 
throw-away location. I haven't yet tried with a pre-existing location.


Could you check and see whether this seems reasonable?

If so, I'll add a check for write access in the working directory to give 
a more sensible error message.


Best wishes,

Roger



Let me know how I can help with testing.
Thanks again

Vero

El mié., 19 sep. 2018 16:31, Roger Bivand  escribió:


Sorry for the delay, now have access to an old laptop with Windows. When
do you need this resolved?

Roger

Roger Bivand
Norwegian School of Economics
Bergen, Norway



Fra: Veronica Andreo
Sendt: mandag 17. september, 02.20
Emne: Re: [GRASS-stats] Error when starting grass from R (grass installed
thru osgeo4w)
Til: Helmut Kudrnovsky
Kopi: grass-stats@lists.osgeo.org


Hi again,

So, I tested as suggested:
1. Open R console within OSGeo4W Shell,
2. library(rgrass7)
3. initGRASS(gisBase = 'C:/OSGeo4W64/apps/grass/grass-7.4.0', gisDbase =
'C:/Users/RETA/Documents/grassdata', location = 'nc_spm_08_grass7', mapset
= 'user1', SG='elevation')

and I now get:
unused argument (gisDbase = 'C:/Users/RETA/Documents/grassdata')

anything else to test/set?

best,
Vero


El dom., 16 sept. 2018 a las 23:15, Helmut Kudrnovsky ()
escribió:


OK, thanks for confirming that OSGeo4W remains feasible for rgrass7; I

don't
have access. Does usability >include initGRASS()? This would be most
fragile
because environment variables are being set, and >condition on Windows and
OSGeo4W.

R within a GRASS session works quite well so far.

did a fresh svn up of

svn://r-forge.r-project.org/svnroot/spgrass

and quickly screened pkg\rgrass7\R\initGRASS.R:

e.g.

Sys.setenv(GRASS_PROJSHARE=paste(Sys.getenv("GISBASE"),
"\\proj", sep=""))

AFAIK at least the GRASS7.4.x line doesn't use anymore an own copy of the
PROJSHARE files; instead it uses the PROJ files itself; that's for all
platforms (linux, MacOS, MS Windows, ...).

e.g. in OSGeo4W 64bit it's defined as:

SET OSGEO4W_ROOT=C:\OSGeo4W64
set GRASS_PROJSHARE=%OSGEO4W_ROOT%\share\proj

only in the standalone installer, it's still defined as:

set GRASS_PROJSHARE=%GISBASE%\share\proj

because it's bundled in the installer.

e.g.

Sys.setenv(PATH=paste(Sys.getenv("GISBASE"), "\\extrabin;",
Sys.getenv("PATH"), sep=""))

there is no C:\OSGeo4W64\apps\grass\grass-7.4.1, because all of the
dependencies etc are living e.g. in
C:\OSGeo4W64\bin, C:\OSGeo4W64\lib, ...

I'm not sure about this one:

[...]
Sys.setenv(GISBASE=gisBase)
if (missing(home)) home <- Sys.getenv("USERPROFILE")
[...]
Sys.setenv(GISRC=paste(Sys.getenv("HOME"), "\\.grassrc7", sep=""))

in winGRASS (standalone, OSGeo4W), the rc file lives in
C:\Users\YourUserName\AppData\Roaming\GRASS7 and not in %USERPROFILE%

and it seems around these lines:

[...]
Sys.setenv(GISRC="junk")
cat("GISDBASE:", getwd(), "\n", file=Sys.getenv("GISRC"))
cat("LOCATION_NAME: ", "\n", file=Sys.getenv("GISRC"),
append=TRUE)
cat("MAPSET: ", "\n", file=Sys.getenv("GISRC"),
append=TRUE)
gisrc <- ifelse (use_g.dirseps.exe, system(paste("g.dirseps.exe
-g",
shQuote(Sys.getenv("GISRC"))), intern=TRUE),
Sys.getenv("GISRC"))
[...]

initGRASS gets in trouble in OSGeo4W.



-
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Stats-f4049448.html
___
grass-stats mailing list
grass-stats@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-stats








--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no
http://orcid.org/-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0J=en___
grass-stats mailing list
grass-stats@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-stats