Using GRASS addons in R on Windows

classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Using GRASS addons in R on Windows

Helmut Kudrnovsky
taken from the GRASS GIS dev ML:

https://lists.osgeo.org/pipermail/grass-dev/2016-January/078318.html

"In Windows running R from within GRASS (latter installed via OSGeo4W)
works fine, except that it can't seem to find the GRASS addons I
installed (with g.extension), not using rgrass7 nor directly using
system(). On Linux this is no problem, I can run any installed addon.
Any ideas how to solve this?"

https://lists.osgeo.org/pipermail/grass-dev/2016-January/078322.html

"> what does echo %PATH% in the osgeo4w shell within the winGRASS session
> print?
>
> is the e.g. C:\Users\xy\AppData\Roaming\GRASS7\addons\bin included?
>

The following is included in the PATH:
C:\OSGeo4W\apps\grass\grass-7.0.2\lib
C:\OSGeo4W\apps\grass\grass-7.0.2\bin
C:\Users\Jeannette\AppData\Roaming\GRASS7\addons\bin
C:\OSGeo4W\apps\msys\bin
C:\OSGeo4W\bin;
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\WBem
C:\OSGeo4W\apps\msys\bin
C:\OSGeo4W\apps\Python27\Scripts;
C:\Program Files\RStudio\bin"

https://lists.osgeo.org/pipermail/grass-dev/2016-January/078327.html

"a quick test here with a py and an exe addon:

r.basin.py

> execGRASS("r.basin", map="elevation", map="elevation", prefix="v",
> coordinates="637500.0,221750.0", dir="C:\tmp", threshold=1000)
Error in system(cmd0, intern = TRUE) : 'r.basin.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) : r.basin not found

r.stream.order.exe

> execGRASS("r.sream.order")
Error in system(cmd0, intern = TRUE) : 'r.sream.order.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) :
  r.sream.order not found

so maybe a question for the GRASS Statistics mailing List?"

best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
On Sat, 9 Jan 2016, Helmut Kudrnovsky wrote:

> taken from the GRASS GIS dev ML:
>
> https://lists.osgeo.org/pipermail/grass-dev/2016-January/078318.html
>
> "In Windows running R from within GRASS (latter installed via OSGeo4W)
> works fine, except that it can't seem to find the GRASS addons I
> installed (with g.extension), not using rgrass7 nor directly using
> system(). On Linux this is no problem, I can run any installed addon.
> Any ideas how to solve this?"
>
> https://lists.osgeo.org/pipermail/grass-dev/2016-January/078322.html
>
> "> what does echo %PATH% in the osgeo4w shell within the winGRASS session
>> print?
>>
>> is the e.g. C:\Users\xy\AppData\Roaming\GRASS7\addons\bin included?
>>

This is not seen by rgrass::parseGRASS(), but a section could be added to
list bin/*.bat files in the GRASS_ADDON_BASE environment variable
directory. Do users also install addons system-wide (there is an option in
the GUI)? Where does install if the -s flag is given - do we need to look
there too?

What happens to C/C++ Windows extensions, are they in the GRASS_ADDON_BASE
\bin with an .exe extension?

Contributions welcome!

Roger

>
> The following is included in the PATH:
> C:\OSGeo4W\apps\grass\grass-7.0.2\lib
> C:\OSGeo4W\apps\grass\grass-7.0.2\bin
> C:\Users\Jeannette\AppData\Roaming\GRASS7\addons\bin
> C:\OSGeo4W\apps\msys\bin
> C:\OSGeo4W\bin;
> C:\WINDOWS\system32
> C:\WINDOWS
> C:\WINDOWS\WBem
> C:\OSGeo4W\apps\msys\bin
> C:\OSGeo4W\apps\Python27\Scripts;
> C:\Program Files\RStudio\bin"
>
> https://lists.osgeo.org/pipermail/grass-dev/2016-January/078327.html
>
> "a quick test here with a py and an exe addon:
>
> r.basin.py
>
>> execGRASS("r.basin", map="elevation", map="elevation", prefix="v",
>> coordinates="637500.0,221750.0", dir="C:\tmp", threshold=1000)
> Error in system(cmd0, intern = TRUE) : 'r.basin.exe' not found
> Error in parseGRASS(cmd, legacyExec = legacyExec) : r.basin not found
>
> r.stream.order.exe
>
>> execGRASS("r.sream.order")
> Error in system(cmd0, intern = TRUE) : 'r.sream.order.exe' not found
> Error in parseGRASS(cmd, legacyExec = legacyExec) :
>  r.sream.order not found
>
> so maybe a question for the GRASS Statistics mailing List?"
>
>
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
>This is not seen by rgrass::parseGRASS(), but a section could be added to
>list bin/*.bat files in the GRASS_ADDON_BASE environment variable
>directory.

the folder structure in C:\Users\xy\AppData\Roaming\GRASS7\addons is the same as in the winGRASS binary installation:

C:\Users\xy\AppData\Roaming\GRASS7\addons
- bin
- docs
- etc
- scripts

some testing:

binary addon:

g.extension extension=r.hydrodem svnurl=http://svn.osgeo.org/grass/grass-addons/grass7
Downloading precompiled GRASS Addons <r.hydrodem>...
Updating addons metadata file...
Installation of <r.hydrodem> successfully finished

r.hydrodem.exe installed in C:\Users\xy\AppData\Roaming\GRASS7\addons\bin

python script addon

g.extension extension=r.basin svnurl=http://svn.osgeo.org/grass/grass-addons/grass7
Downloading precompiled GRASS Addons <r.basin>...
Updating addons metadata file...
Installation of <r.basin> successfully finished

r.basin.bat installed in C:\Users\xy\AppData\Roaming\GRASS7\addons\bin
r.basin.py installed in C:\Users\xy\AppData\Roaming\GRASS7\addons\scripts

---------------

system wide installation

binary addon:

g.extension -s extension=r.geomorphon svnurl=http://svn.osgeo.org/grass/grass-addons/grass7
Downloading precompiled GRASS Addons <r.geomorphon>...
Updating addons metadata file...
Installation of <r.geomorphon> successfully finished

r.geomorphon installed in e.g. C:\OSGeo4W\apps\grass\grass-7.0.3RC1\bin

python script addon:

g.extension -s extension=r.euro.ecosystem svnurl=http://svn.osgeo.org/grass/grass-addons/grass7
Downloading precompiled GRASS Addons <r.euro.ecosystem>...
Updating addons metadata file...
Installation of <r.euro.ecosystem> successfully finished

r.euro.ecosystem.bat installed in C:\OSGeo4W\apps\grass\grass-7.0.3RC1\bin
r.euro.ecosystem.py installed in C:\OSGeo4W\apps\grass\grass-7.0.3RC1\scripts

>Do users also install addons system-wide (there is an option in
>the GUI)? Where does install if the -s flag is given - do we need to look
>there too?

by the -s flag in the winGRASS installation folder (e.g. C:\OSGeo4W\apps\grass\grass-7.0.3RC1); so no further scan is needed. AFAIU -s may only work in a OSGeo4W-installation but not in a winGRASS standalone installation as for the the latter permissions rights are needed to install in C:\Program Files and I'm not sure this is handled by g.extension in winGRASS

>What happens to C/C++ Windows extensions, are they in the GRASS_ADDON_BASE
>\bin with an .exe extension?

binary addons (C/C++ Windows extensions) have an .exe extension and live in \bin; python addons have a related .bat-script (see above) in \bin, the script itself is in \script
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
In reply to this post by Roger Bivand
> Contributions welcome!

this thread is about rgrass7 and winGRASS7.

just found https://github.com/cran/rgrass7

where to look? maybe here: https://github.com/cran/rgrass7/blob/master/R/xml1.R ?

(un)related:

https://github.com/cran/rgrass7/blob/master/R/initGRASS.R#L42

it references to grass63.bat; regarding winGRASS7 there were many changes for starting, some of variables mentioned in L42 below aren't no longer there (e.g. [1]).

should these also be updated?

[1] https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/mswindows/env.bat
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
On Sun, 10 Jan 2016, Helmut Kudrnovsky wrote:

>> Contributions welcome!
>
> this thread is about rgrass7 and winGRASS7.
>
> just found https://github.com/cran/rgrass7
>
> where to look? maybe here:
> https://github.com/cran/rgrass7/blob/master/R/xml1.R ?
>

No, of course not. Github is used by Gabor Csardi without the consent of
the authors or maintainers of packages to give fashionable access to work
(not done by the copiers who have a dictatorial frame of mind) that is
completely accessible elsewhere:

https://r-forge.r-project.org/projects/spgrass/

using SVN. The underlying MetaCRAN "project" does say: "Unofficial
read-only mirror of all CRAN R packages", which is accurate - it is used
for some rather misleading metrics designed largely to boost the value of
R Studio (IMHO). It is *not* a development repository.

To contribute, either ask for contributor status and checkout with a user
name, committing only after successful R CMD check --as-cran on a fresh
tarball, or send patch files to the maintainer after checking out
anonymously. The successful R CMD check --as-cran on a fresh tarball is
the crucial step, especially across relevant platforms. The github mindset
is to hope that travis is set up right to do cross-platform testing, which
it largely isn't; the eyes of developers are often far more perceptive -
provided that the checking/testing is done (here with NC basic).

My guess is that the addons/bin also needs to be searched (possibly twice,
once for *.bat, again for *.exe) in xml1.R.

> (un)related:
>
> https://github.com/cran/rgrass7/blob/master/R/initGRASS.R#L42
>

This is irrelevant here - see rather R/AAA.R:

https://r-forge.r-project.org/scm/viewvc.php/pkg/rgrass7/R/AAA.R?view=markup&revision=24&root=spgrass

Both need to be progressed to GRASS 7, as does the exclusion list at the
head of R/xml1.R

Best wishes,

Roger


> it references to grass63.bat; regarding winGRASS7 there were many changes
> for starting, some of variables mentioned in L42 below aren't no longer
> there (e.g. [1]).
>
> should these also be updated?
>
> [1]
> https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/mswindows/env.bat
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411p5244459.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
>completely accessible elsewhere:
>
>https://r-forge.r-project.org/projects/spgrass/
>
>using SVN.

I've done a SVN checkout.

I'm not sure that I can contribute code diffs, but here are some test findings:

> library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.0.3RC1 (2015)
and location: nc_spm_08_grass7

-------------------

AFAIK msys is dropped in winGRASS7

C:\tmp\rg\rgrass7\pkg\rgrass7\R\AAA.R

  SYS <- ""
  if (.Platform$OS.type == "windows") {
    if (Sys.getenv("OSTYPE") == "msys") SYS <- "msys"
    else SYS <- "WinNat"
  } else if (.Platform$OS.type == "unix") SYS <- "unix"
  assign("SYS", SYS, envir=.GRASS_CACHE)
 
   res <- ""
  if (SYS == "msys" || SYS == "WinNat") res =".exe"
  assign("addEXE", res, envir=.GRASS_CACHE)
  assign("WN_bat", "", envir=.GRASS_CACHE)
 
> t1 <- .Platform$OS.type
> t1
[1] "windows"
> t2 <- Sys.getenv("OSTYPE")
> t2
[1] ""
>

so maybe simplified to:

  if (.Platform$OS.type == "windows") SYS <- "WinNat"
  else if (.Platform$OS.type == "unix") SYS <- "unix"
[...]
  if (SYS == "WinNat") res =".exe"
  assign("addEXE", res, envir=.GRASS_CACHE)
 
 

  if (SYS == "WinNat" && nchar(gisrc) > 0) {
    pyScripts <- basename(list.files(paste(Sys.getenv("WINGISBASE"),
      "scripts", sep="/"), pattern="py$"))
    names(pyScripts) <- sub("\\.py", "", pyScripts)
    assign("pyScripts", pyScripts, envir=.GRASS_CACHE)
       
> t3 <- Sys.getenv("WINGISBASE")
> t3
[1] ""
> t4 <- Sys.getenv("GISBASE")
> t4
[1] "C:\\OSGEO4~1\\apps\\grass\\grass-7.0.3RC1"
> t5 <- Sys.getenv("GRASS_ADDON_BASE")
> t5
[1] "C:\\Users\\myricaria\\AppData\\Roaming\\GRASS7\\addons"

> pyScripts <- basename(list.files(paste(Sys.getenv("GISBASE"), "scripts", "scripts", sep="/"), pattern="py$"))
> pyScripts
  [1] "d.correlate.py"          "d.out.file.py"
  [3] "d.polar.py"              "d.rast.edit.py"
  [5] "d.rast.leg.py"           "d.redraw.py"
  [7] "d.shade.py"              "d.to.rast.py"
  [9] "d.what.rast.py"          "d.what.vect.py"
 [11] "db.dropcolumn.py"        "db.droptable.py"
 [13] "db.in.ogr.py"            "db.out.ogr.py"
 [15] "db.test.py"              "db.univar.py"
 [17] "g.extension.all.py"      "g.extension.py"
 [19] "g.gui.animation.py"      "g.gui.dbmgr.py"
 [21] "g.gui.gcp.py"            "g.gui.gmodeler.py"
 [23] "g.gui.iclass.py"         "g.gui.mapswipe.py"
 [25] "g.gui.psmap.py"          "g.gui.rlisetup.py"
 [27] "g.gui.timeline.py"       "g.gui.tplot.py"
 [29] "g.gui.vdigit.py"         "g.manual.py"
 [31] "i.colors.enhance.py"     "i.image.mosaic.py"
 [33] "i.in.spotvgt.py"         "i.oif.py"
 [35] "i.pansharpen.py"         "i.spectral.py"
 [37] "i.tasscap.py"            "m.proj.py"
 [39] "r.blend.py"              "r.buffer.lowmem.py"
 [41] "r.colors.stddev.py"      "r.fillnulls.py"
 [43] "r.grow.py"               "r.import.py"
 [45] "r.in.aster.py"           "r.in.srtm.py"
 [47] "r.in.wms.py"             "r.mask.py"
 [49] "r.out.xyz.py"            "r.pack.py"
 [51] "r.plane.py"              "r.reclass.area.py"
 [53] "r.rgb.py"                "r.shade.py"
 [55] "r.tileset.py"            "r.unpack.py"
 [57] "r3.in.xyz.py"            "t.create.py"
 [59] "t.info.py"               "t.list.py"
 [61] "t.merge.py"              "t.rast.accdetect.py"
 [63] "t.rast.accumulate.py"    "t.rast.aggregate.ds.py"
 [65] "t.rast.aggregate.py"     "t.rast.colors.py"
 [67] "t.rast.export.py"        "t.rast.extract.py"
 [69] "t.rast.gapfill.py"       "t.rast.import.py"
 [71] "t.rast.list.py"          "t.rast.mapcalc.py"
 [73] "t.rast.neighbors.py"     "t.rast.out.vtk.py"
 [75] "t.rast.series.py"        "t.rast.to.rast3.py"
 [77] "t.rast.univar.py"        "t.rast3d.extract.py"
 [79] "t.rast3d.list.py"        "t.rast3d.mapcalc.py"
 [81] "t.rast3d.univar.py"      "t.register.py"
 [83] "t.remove.py"             "t.rename.py"
 [85] "t.sample.py"             "t.select.py"
 [87] "t.shift.py"              "t.snap.py"
 [89] "t.support.py"            "t.topology.py"
 [91] "t.unregister.py"         "t.vect.db.select.py"
 [93] "t.vect.export.py"        "t.vect.extract.py"
 [95] "t.vect.import.py"        "t.vect.list.py"
 [97] "t.vect.observe.strds.py" "t.vect.univar.py"
 [99] "t.vect.what.strds.py"    "v.build.all.py"
[101] "v.centroids.py"          "v.db.addcolumn.py"
[103] "v.db.addtable.py"        "v.db.dropcolumn.py"
[105] "v.db.droprow.py"         "v.db.droptable.py"
[107] "v.db.join.py"            "v.db.reconnect.all.py"
[109] "v.db.renamecolumn.py"    "v.db.univar.py"
[111] "v.db.update.py"          "v.dissolve.py"
[113] "v.import.py"             "v.in.e00.py"
[115] "v.in.geonames.py"        "v.in.lines.py"
[117] "v.in.mapgen.py"          "v.in.wfs.py"
[119] "v.krige.py"              "v.pack.py"
[121] "v.rast.stats.py"         "v.report.py"
[123] "v.to.lines.py"           "v.unpack.py"
[125] "v.what.strds.py"         "v.what.vect.py"
[127] "wxpyimgview.py"
>

AFAIK variable %WINGISBASE% isn't there anymore in winGRASS7, it's now %GISBASE%
-------------------

C:\tmp\rg\rgrass7\pkg\rgrass7\R\rgrass.R

.addexe <- function() {
    res <- ""
    SYS <- get("SYS", envir=.GRASS_CACHE)
    if (SYS == "msys" || SYS == "WinNat") res =".exe"
    res
}

maybe simplified to:

    if (SYS == "WinNat") res =".exe"

-------------------

C:\tmp\rg\rgrass7\pkg\rgrass7\R\xml1.R

    bin_out_win <- c("d.colors.exe", "d.save.exe", "d.what.rast.exe",
      "d.what.vect.exe", "d.zoom.exe", "g.parser.exe", "gis.m.bat",
      "i.spectral.bat", "mkftcap.bat", "r.mapcalc.exe", "r.tileset.bat",
      "r3.mapcalc.exe", "v.in.gpsbabel.bat", "v.proj.exe")
         
"gis.m.bat" -> AFAIK gis.m is dropped in GRASS7
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
In reply to this post by Roger Bivand
>My guess is that the addons/bin also needs to be searched (possibly twice,
>once for *.bat, again for *.exe) in xml1.R.

yes I think so.
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
In reply to this post by Helmut Kudrnovsky
On Mon, 11 Jan 2016, Helmut Kudrnovsky wrote:

>> completely accessible elsewhere:
>>
>> https://r-forge.r-project.org/projects/spgrass/
>>
>> using SVN.
>
> I've done a SVN checkout.
>
> I'm not sure that I can contribute code diffs, but here are some test
> findings:


OK, thanks. SVN commited revisions at # 45. I've sent a build request to R
Winbuilder to get a regular Windows rgrass7 binary, ready now at:

http://win-builder.r-project.org/s90s00N7rhyt/

WN_bat should now include *.bat files in GRASS_ADDON_BASE, which is in the
PATH for me using Windows Native (not checked with OSGeo4W). References to
msys and WINGISBASE removed.

Comments welcome,

Roger

>
>> library(rgrass7)
> Loading required package: sp
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: GRASS 7.0.3RC1 (2015)
> and location: nc_spm_08_grass7
>
> -------------------
>
> AFAIK msys is dropped in winGRASS7
>
> C:\tmp\rg\rgrass7\pkg\rgrass7\R\AAA.R
>
>  SYS <- ""
>  if (.Platform$OS.type == "windows") {
>    if (Sys.getenv("OSTYPE") == "msys") SYS <- "msys"
>    else SYS <- "WinNat"
>  } else if (.Platform$OS.type == "unix") SYS <- "unix"
>  assign("SYS", SYS, envir=.GRASS_CACHE)
>
>   res <- ""
>  if (SYS == "msys" || SYS == "WinNat") res =".exe"
>  assign("addEXE", res, envir=.GRASS_CACHE)
>  assign("WN_bat", "", envir=.GRASS_CACHE)
>
>> t1 <- .Platform$OS.type
>> t1
> [1] "windows"
>> t2 <- Sys.getenv("OSTYPE")
>> t2
> [1] ""
>>
>
> so maybe simplified to:
>
>  if (.Platform$OS.type == "windows") SYS <- "WinNat"
>  else if (.Platform$OS.type == "unix") SYS <- "unix"
> [...]
>  if (SYS == "WinNat") res =".exe"
>  assign("addEXE", res, envir=.GRASS_CACHE)
>
>
>
>  if (SYS == "WinNat" && nchar(gisrc) > 0) {
>    pyScripts <- basename(list.files(paste(Sys.getenv("WINGISBASE"),
>      "scripts", sep="/"), pattern="py$"))
>    names(pyScripts) <- sub("\\.py", "", pyScripts)
>    assign("pyScripts", pyScripts, envir=.GRASS_CACHE)
>
>> t3 <- Sys.getenv("WINGISBASE")
>> t3
> [1] ""
>> t4 <- Sys.getenv("GISBASE")
>> t4
> [1] "C:\\OSGEO4~1\\apps\\grass\\grass-7.0.3RC1"
>> t5 <- Sys.getenv("GRASS_ADDON_BASE")
>> t5
> [1] "C:\\Users\\myricaria\\AppData\\Roaming\\GRASS7\\addons"
>
>> pyScripts <- basename(list.files(paste(Sys.getenv("GISBASE"), "scripts",
>> "scripts", sep="/"), pattern="py$"))
>> pyScripts
>  [1] "d.correlate.py"          "d.out.file.py"
>  [3] "d.polar.py"              "d.rast.edit.py"
>  [5] "d.rast.leg.py"           "d.redraw.py"
>  [7] "d.shade.py"              "d.to.rast.py"
>  [9] "d.what.rast.py"          "d.what.vect.py"
> [11] "db.dropcolumn.py"        "db.droptable.py"
> [13] "db.in.ogr.py"            "db.out.ogr.py"
> [15] "db.test.py"              "db.univar.py"
> [17] "g.extension.all.py"      "g.extension.py"
> [19] "g.gui.animation.py"      "g.gui.dbmgr.py"
> [21] "g.gui.gcp.py"            "g.gui.gmodeler.py"
> [23] "g.gui.iclass.py"         "g.gui.mapswipe.py"
> [25] "g.gui.psmap.py"          "g.gui.rlisetup.py"
> [27] "g.gui.timeline.py"       "g.gui.tplot.py"
> [29] "g.gui.vdigit.py"         "g.manual.py"
> [31] "i.colors.enhance.py"     "i.image.mosaic.py"
> [33] "i.in.spotvgt.py"         "i.oif.py"
> [35] "i.pansharpen.py"         "i.spectral.py"
> [37] "i.tasscap.py"            "m.proj.py"
> [39] "r.blend.py"              "r.buffer.lowmem.py"
> [41] "r.colors.stddev.py"      "r.fillnulls.py"
> [43] "r.grow.py"               "r.import.py"
> [45] "r.in.aster.py"           "r.in.srtm.py"
> [47] "r.in.wms.py"             "r.mask.py"
> [49] "r.out.xyz.py"            "r.pack.py"
> [51] "r.plane.py"              "r.reclass.area.py"
> [53] "r.rgb.py"                "r.shade.py"
> [55] "r.tileset.py"            "r.unpack.py"
> [57] "r3.in.xyz.py"            "t.create.py"
> [59] "t.info.py"               "t.list.py"
> [61] "t.merge.py"              "t.rast.accdetect.py"
> [63] "t.rast.accumulate.py"    "t.rast.aggregate.ds.py"
> [65] "t.rast.aggregate.py"     "t.rast.colors.py"
> [67] "t.rast.export.py"        "t.rast.extract.py"
> [69] "t.rast.gapfill.py"       "t.rast.import.py"
> [71] "t.rast.list.py"          "t.rast.mapcalc.py"
> [73] "t.rast.neighbors.py"     "t.rast.out.vtk.py"
> [75] "t.rast.series.py"        "t.rast.to.rast3.py"
> [77] "t.rast.univar.py"        "t.rast3d.extract.py"
> [79] "t.rast3d.list.py"        "t.rast3d.mapcalc.py"
> [81] "t.rast3d.univar.py"      "t.register.py"
> [83] "t.remove.py"             "t.rename.py"
> [85] "t.sample.py"             "t.select.py"
> [87] "t.shift.py"              "t.snap.py"
> [89] "t.support.py"            "t.topology.py"
> [91] "t.unregister.py"         "t.vect.db.select.py"
> [93] "t.vect.export.py"        "t.vect.extract.py"
> [95] "t.vect.import.py"        "t.vect.list.py"
> [97] "t.vect.observe.strds.py" "t.vect.univar.py"
> [99] "t.vect.what.strds.py"    "v.build.all.py"
> [101] "v.centroids.py"          "v.db.addcolumn.py"
> [103] "v.db.addtable.py"        "v.db.dropcolumn.py"
> [105] "v.db.droprow.py"         "v.db.droptable.py"
> [107] "v.db.join.py"            "v.db.reconnect.all.py"
> [109] "v.db.renamecolumn.py"    "v.db.univar.py"
> [111] "v.db.update.py"          "v.dissolve.py"
> [113] "v.import.py"             "v.in.e00.py"
> [115] "v.in.geonames.py"        "v.in.lines.py"
> [117] "v.in.mapgen.py"          "v.in.wfs.py"
> [119] "v.krige.py"              "v.pack.py"
> [121] "v.rast.stats.py"         "v.report.py"
> [123] "v.to.lines.py"           "v.unpack.py"
> [125] "v.what.strds.py"         "v.what.vect.py"
> [127] "wxpyimgview.py"
>>
>
> AFAIK variable %WINGISBASE% isn't there anymore in winGRASS7, it's now
> %GISBASE%
> -------------------
>
> C:\tmp\rg\rgrass7\pkg\rgrass7\R\rgrass.R
>
> .addexe <- function() {
>    res <- ""
>    SYS <- get("SYS", envir=.GRASS_CACHE)
>    if (SYS == "msys" || SYS == "WinNat") res =".exe"
>    res
> }
>
> maybe simplified to:
>
>    if (SYS == "WinNat") res =".exe"
>
> -------------------
>
> C:\tmp\rg\rgrass7\pkg\rgrass7\R\xml1.R
>
>    bin_out_win <- c("d.colors.exe", "d.save.exe", "d.what.rast.exe",
>      "d.what.vect.exe", "d.zoom.exe", "g.parser.exe", "gis.m.bat",
>      "i.spectral.bat", "mkftcap.bat", "r.mapcalc.exe", "r.tileset.bat",
>      "r3.mapcalc.exe", "v.in.gpsbabel.bat", "v.proj.exe")
>
> "gis.m.bat" -> AFAIK gis.m is dropped in GRASS7
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411p5244520.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
The link is *not* to CRAN, and a lot more testing will  be needed before I even submit to CRAN - re your link from GRASS-dev to this thread. I need to know that use cases of g.extensions installed workflows now succeed where previously they failed for OSGeo4W and native Windows builds of GRASS. CRAN isn't used for speculating about possibilities that things might (or might not) work - that is R-forge, from which you may svn update, then R CMD build rgrass7, then R CMD INSTALL --build rgrass7_0.1-4.tar.gz (using RTools), then install from local zip file, then run the workflow.

There are other pending edits to vector file transfer on Windows, so the extensions issue isn't alone enough to trigger a submission to CRAN.

Roger

--
Roger Bivand
Norwegian School of Economics
Helleveien 30, 5045 Bergen, Norway
[hidden email]


________________________________________
Fra: grass-stats [[hidden email]] p&#229; vegne av Roger Bivand [[hidden email]]
Sendt: 11. januar 2016 3:06
Til: Helmut Kudrnovsky
Kopi: [hidden email]
Emne: Re: [GRASS-stats] Using GRASS addons in R on Windows

On Mon, 11 Jan 2016, Helmut Kudrnovsky wrote:

>> completely accessible elsewhere:
>>
>> https://r-forge.r-project.org/projects/spgrass/
>>
>> using SVN.
>
> I've done a SVN checkout.
>
> I'm not sure that I can contribute code diffs, but here are some test
> findings:


OK, thanks. SVN commited revisions at # 45. I've sent a build request to R
Winbuilder to get a regular Windows rgrass7 binary, ready now at:

http://win-builder.r-project.org/s90s00N7rhyt/

WN_bat should now include *.bat files in GRASS_ADDON_BASE, which is in the
PATH for me using Windows Native (not checked with OSGeo4W). References to
msys and WINGISBASE removed.

Comments welcome,

Roger

>
>> library(rgrass7)
> Loading required package: sp
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: GRASS 7.0.3RC1 (2015)
> and location: nc_spm_08_grass7
>
> -------------------
>
> AFAIK msys is dropped in winGRASS7
>
> C:\tmp\rg\rgrass7\pkg\rgrass7\R\AAA.R
>
>  SYS <- ""
>  if (.Platform$OS.type == "windows") {
>    if (Sys.getenv("OSTYPE") == "msys") SYS <- "msys"
>    else SYS <- "WinNat"
>  } else if (.Platform$OS.type == "unix") SYS <- "unix"
>  assign("SYS", SYS, envir=.GRASS_CACHE)
>
>   res <- ""
>  if (SYS == "msys" || SYS == "WinNat") res =".exe"
>  assign("addEXE", res, envir=.GRASS_CACHE)
>  assign("WN_bat", "", envir=.GRASS_CACHE)
>
>> t1 <- .Platform$OS.type
>> t1
> [1] "windows"
>> t2 <- Sys.getenv("OSTYPE")
>> t2
> [1] ""
>>
>
> so maybe simplified to:
>
>  if (.Platform$OS.type == "windows") SYS <- "WinNat"
>  else if (.Platform$OS.type == "unix") SYS <- "unix"
> [...]
>  if (SYS == "WinNat") res =".exe"
>  assign("addEXE", res, envir=.GRASS_CACHE)
>
>
>
>  if (SYS == "WinNat" && nchar(gisrc) > 0) {
>    pyScripts <- basename(list.files(paste(Sys.getenv("WINGISBASE"),
>      "scripts", sep="/"), pattern="py$"))
>    names(pyScripts) <- sub("\\.py", "", pyScripts)
>    assign("pyScripts", pyScripts, envir=.GRASS_CACHE)
>
>> t3 <- Sys.getenv("WINGISBASE")
>> t3
> [1] ""
>> t4 <- Sys.getenv("GISBASE")
>> t4
> [1] "C:\\OSGEO4~1\\apps\\grass\\grass-7.0.3RC1"
>> t5 <- Sys.getenv("GRASS_ADDON_BASE")
>> t5
> [1] "C:\\Users\\myricaria\\AppData\\Roaming\\GRASS7\\addons"
>
>> pyScripts <- basename(list.files(paste(Sys.getenv("GISBASE"), "scripts",
>> "scripts", sep="/"), pattern="py$"))
>> pyScripts
>  [1] "d.correlate.py"          "d.out.file.py"
>  [3] "d.polar.py"              "d.rast.edit.py"
>  [5] "d.rast.leg.py"           "d.redraw.py"
>  [7] "d.shade.py"              "d.to.rast.py"
>  [9] "d.what.rast.py"          "d.what.vect.py"
> [11] "db.dropcolumn.py"        "db.droptable.py"
> [13] "db.in.ogr.py"            "db.out.ogr.py"
> [15] "db.test.py"              "db.univar.py"
> [17] "g.extension.all.py"      "g.extension.py"
> [19] "g.gui.animation.py"      "g.gui.dbmgr.py"
> [21] "g.gui.gcp.py"            "g.gui.gmodeler.py"
> [23] "g.gui.iclass.py"         "g.gui.mapswipe.py"
> [25] "g.gui.psmap.py"          "g.gui.rlisetup.py"
> [27] "g.gui.timeline.py"       "g.gui.tplot.py"
> [29] "g.gui.vdigit.py"         "g.manual.py"
> [31] "i.colors.enhance.py"     "i.image.mosaic.py"
> [33] "i.in.spotvgt.py"         "i.oif.py"
> [35] "i.pansharpen.py"         "i.spectral.py"
> [37] "i.tasscap.py"            "m.proj.py"
> [39] "r.blend.py"              "r.buffer.lowmem.py"
> [41] "r.colors.stddev.py"      "r.fillnulls.py"
> [43] "r.grow.py"               "r.import.py"
> [45] "r.in.aster.py"           "r.in.srtm.py"
> [47] "r.in.wms.py"             "r.mask.py"
> [49] "r.out.xyz.py"            "r.pack.py"
> [51] "r.plane.py"              "r.reclass.area.py"
> [53] "r.rgb.py"                "r.shade.py"
> [55] "r.tileset.py"            "r.unpack.py"
> [57] "r3.in.xyz.py"            "t.create.py"
> [59] "t.info.py"               "t.list.py"
> [61] "t.merge.py"              "t.rast.accdetect.py"
> [63] "t.rast.accumulate.py"    "t.rast.aggregate.ds.py"
> [65] "t.rast.aggregate.py"     "t.rast.colors.py"
> [67] "t.rast.export.py"        "t.rast.extract.py"
> [69] "t.rast.gapfill.py"       "t.rast.import.py"
> [71] "t.rast.list.py"          "t.rast.mapcalc.py"
> [73] "t.rast.neighbors.py"     "t.rast.out.vtk.py"
> [75] "t.rast.series.py"        "t.rast.to.rast3.py"
> [77] "t.rast.univar.py"        "t.rast3d.extract.py"
> [79] "t.rast3d.list.py"        "t.rast3d.mapcalc.py"
> [81] "t.rast3d.univar.py"      "t.register.py"
> [83] "t.remove.py"             "t.rename.py"
> [85] "t.sample.py"             "t.select.py"
> [87] "t.shift.py"              "t.snap.py"
> [89] "t.support.py"            "t.topology.py"
> [91] "t.unregister.py"         "t.vect.db.select.py"
> [93] "t.vect.export.py"        "t.vect.extract.py"
> [95] "t.vect.import.py"        "t.vect.list.py"
> [97] "t.vect.observe.strds.py" "t.vect.univar.py"
> [99] "t.vect.what.strds.py"    "v.build.all.py"
> [101] "v.centroids.py"          "v.db.addcolumn.py"
> [103] "v.db.addtable.py"        "v.db.dropcolumn.py"
> [105] "v.db.droprow.py"         "v.db.droptable.py"
> [107] "v.db.join.py"            "v.db.reconnect.all.py"
> [109] "v.db.renamecolumn.py"    "v.db.univar.py"
> [111] "v.db.update.py"          "v.dissolve.py"
> [113] "v.import.py"             "v.in.e00.py"
> [115] "v.in.geonames.py"        "v.in.lines.py"
> [117] "v.in.mapgen.py"          "v.in.wfs.py"
> [119] "v.krige.py"              "v.pack.py"
> [121] "v.rast.stats.py"         "v.report.py"
> [123] "v.to.lines.py"           "v.unpack.py"
> [125] "v.what.strds.py"         "v.what.vect.py"
> [127] "wxpyimgview.py"
>>
>
> AFAIK variable %WINGISBASE% isn't there anymore in winGRASS7, it's now
> %GISBASE%
> -------------------
>
> C:\tmp\rg\rgrass7\pkg\rgrass7\R\rgrass.R
>
> .addexe <- function() {
>    res <- ""
>    SYS <- get("SYS", envir=.GRASS_CACHE)
>    if (SYS == "msys" || SYS == "WinNat") res =".exe"
>    res
> }
>
> maybe simplified to:
>
>    if (SYS == "WinNat") res =".exe"
>
> -------------------
>
> C:\tmp\rg\rgrass7\pkg\rgrass7\R\xml1.R
>
>    bin_out_win <- c("d.colors.exe", "d.save.exe", "d.what.rast.exe",
>      "d.what.vect.exe", "d.zoom.exe", "g.parser.exe", "gis.m.bat",
>      "i.spectral.bat", "mkftcap.bat", "r.mapcalc.exe", "r.tileset.bat",
>      "r3.mapcalc.exe", "v.in.gpsbabel.bat", "v.proj.exe")
>
> "gis.m.bat" -> AFAIK gis.m is dropped in GRASS7
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411p5244520.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
>The link is *not* to CRAN, and a lot more testing will  be needed before I even submit to CRAN - re your link from GRASS-dev to this thread. I need to know that use cases of g.extensions installed workflows now succeed where previously they failed for OSGeo4W and native Windows builds of GRASS. CRAN isn't used for speculating about possibilities that things might (or might not) work - that is R-forge, from which you may svn update, then R CMD build rgrass7, then R CMD INSTALL --build rgrass7_0.1-4.tar.gz (using RTools), then install from local zip file, then run the workflow.
>
>There are other pending edits to vector file transfer on Windows, so the extensions issue isn't alone enough to trigger a submission to CRAN.

thanks for the clarification.

tested now:

-----------------------

versuche URL 'http://R-Forge.R-project.org/bin/windows/contrib/3.2/rgrass7_0.1-4.zip'
Content type 'application/zip' length 85081 bytes (83 KB)
downloaded 83 KB

-----------------------

GRASS version: 7.0.3RC1                                                        
GRASS SVN Revision: 67443                                                      
Build Date: 2015-12-31                                                          
Build Platform: x86_64-w64-mingw32                                              
GDAL/OGR: 1.11.3                                                                
PROJ.4: 4.9.2                                                                  
GEOS: 3.5.0                                                                    
SQLite: 3.7.17                                                                  
Python: 2.7.5                                                                  
wxPython: 2.8.12.1                                                              
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

-----------------------

binary addon (r.stream.order)

in GRASS:

r.watershed elevation=elevation@PERMANENT threshold=10000 accumulation=myaccum drainage=myflowdir stream=mystreams
r.stream.order stream_rast=mystreams@rtestw64bit direction=myflowdir@rtestw64bit elevation=elevation@PERMANENT accumulation=myaccum@rtestw64bit strahler=mystrahler

in R:

> library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.0.3RC1 (2015)
and location: nc_spm_08_grass7

execGRASS("r.watershed", elevation="elevation", threshold=10000, accumulation="myaccum", drainage="myflowdir", stream="mystreams")

> execGRASS("r.watershed", elevation="elevation", threshold=10000, accumulatio$ ...
SECTION 1a (of 5): Initiating Memory.
SECTION 1b (of 5): Determining Offmap Flow.
 100%
SECTION 2: A* Search.
 100%
SECTION 3a: Accumulating Surface Flow with MFD.
 100%
SECTION 3b: Adjusting drainage directions.
 100%
SECTION 4: Watershed determination.
 100%
SECTION 5: Closing Maps.
 100%

execGRASS("r.stream.order", stream_rast="mystreams", direction="myflowdir", elevation="elevation", accumulation="myaccum", strahler="mystrahler")

> execGRASS("r.stream.order", stream_rast="mystreams", direction="myflowdir", $ ...
All in RAM calculation...
Reading raster map <mystreams>...
 100%
Reading raster map <myflowdir>...
 100%
Finding nodes...
Calculating Strahler's stream order...
Writing output raster maps...

-----------------------

python addon (r.roughness.vector):

in GRASS:

r.slope.aspect elevation=elevation@PERMANENT slope=myslope aspect=myaspect
r.roughness.vector elevation=elevation@PERMANENT slope=myslope@rtestw64bit aspect=myaspect@rtestw64bit strength=vectorstrength

in R:

execGRASS("r.slope.aspect", elevation="elevation", slope="myslope", aspect="myaspect")

> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope", aspect="$
 100%
Aspect raster map <myaspect> complete
Slope raster map <myslope> complete

execGRASS("r.roughness.vector", elevation="elevation", slope="myslope", aspect="myaspect", strength="vectorstrength")

> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope", aspe$
Error in system(cmd0, intern = TRUE) : 'r.roughness.vector.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) :
  r.roughness.vector not found

-----------------------

python GRASS script (r.reclass.area):

in GRASS:

r.reclass.area input=zipcodes@PERMANENT output=zipcode_larger2000ha value=2000 mode=greater

in R:

execGRASS("r.reclass.area", input="zipcodes", output="zipcode_larger2000ha", value=2000, mode="greater")

> execGRASS("r.reclass.area", input="zipcodes", output="zipcode_larger2000ha",$
Error in system(cmd0, intern = TRUE) : 'r.reclass.area.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) :
  r.reclass.area not found
 
-----------------------  

in summary (tested in OSGeo4W-winGRASS):

- binary addon (e.g. r.stream.order) is reckognized and can be run via execGRASS
- python scripts (python GRASS GIS scripts e.g. r.reclass.area _and_ python addon scripts) aren't found; it seems it is searched for an .exe, in winGRASS these scripts are started by a related .bat-file.


best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
In reply to this post by Roger Bivand
>The link is *not* to CRAN, and a lot more testing will  be needed before I even submit to CRAN - re your link from GRASS-dev to this thread. I need to know that use cases of g.extensions installed workflows now succeed where previously they failed for OSGeo4W and native Windows builds of GRASS. CRAN isn't used for speculating about possibilities that things might (or might not) work - that is R-forge, from which you may svn update, then R CMD build rgrass7, then R CMD INSTALL --build rgrass7_0.1-4.tar.gz (using RTools), then install from local zip file, then run the workflow.

>There are other pending edits to vector file transfer on Windows, so the extensions issue isn't alone enough to trigger a submission to CRAN.

now tested with winGRASS standalone:

-----------------------  

GRASS version: 7.1.svn                                                          
GRASS SVN revision: 67543                                                      
Build date: 2016-01-11                                                          
Build platform: x86_64-w64-mingw32                                              
GDAL: 1.11.3                                                                    
PROJ.4: 4.9.2                                                                  
GEOS: 3.5.0                                                                    
SQLite: 3.7.17                                                                  
Python: 2.7.5                                                                  
wxPython: 2.8.12.1                                                              
Platform: Windows-7-6.1.7601-SP1  

-----------------------

> execGRASS("r.watershed", elevation="elevation", threshold=10000, accumulatio$
SECTION 1a (of 5): Initiating Memory.
SECTION 1b (of 5): Determining Offmap Flow.
 100%
SECTION 2: A* Search.
 100%
SECTION 3a: Accumulating Surface Flow with MFD.
 100%
SECTION 3b: Adjusting drainage directions.
 100%
SECTION 4: Watershed determination.
 100%
SECTION 5: Closing Maps.
 100%

-----------------------

> execGRASS("r.stream.order", stream_rast="mystreams", direction="myflowdir", $
All in RAM calculation...
Reading raster map <mystreams>...
 100%
Reading raster map <myflowdir>...
 100%
Finding nodes...
Calculating Strahler's stream order...
Writing output raster maps...

-----------------------

> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope", aspect="$
 100%
Aspect raster map <myaspect> complete
Slope raster map <myslope> complete

-----------------------

> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope", aspe$
Error in system(cmd0, intern = TRUE) : 'r.roughness.vector.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) :
  r.roughness.vector not found

-----------------------

> execGRASS("r.reclass.area", input="zipcodes", output="zipcode_larger2000ha",$
Error in system(cmd0, intern = TRUE) : 'r.reclass.area.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) :
  r.reclass.area not found

-----------------------

it seems to be same that python scripts (python GRASS GIS scripts and python addon scripts) aren't reckognized.
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
In reply to this post by Helmut Kudrnovsky
On Mon, 11 Jan 2016, Helmut Kudrnovsky wrote:

>> The link is *not* to CRAN, and a lot more testing will  be needed before I
> even submit to CRAN - re your link from GRASS-dev to this thread. I need to
> know that use cases of g.extensions installed workflows now succeed where
> previously they failed for OSGeo4W and native Windows builds of GRASS. CRAN
> isn't used for speculating about possibilities that things might (or might
> not) work - that is R-forge, from which you may svn update, then R CMD build
> rgrass7, then R CMD INSTALL --build rgrass7_0.1-4.tar.gz (using RTools),
> then install from local zip file, then run the workflow.
>>
>> There are other pending edits to vector file transfer on Windows, so the
> extensions issue isn't alone enough to trigger a submission to CRAN.
>
> thanks for the clarification.
>
> tested now:
>
> -----------------------
>
> versuche URL
> 'http://R-Forge.R-project.org/bin/windows/contrib/3.2/rgrass7_0.1-4.zip'
> Content type 'application/zip' length 85081 bytes (83 KB)
> downloaded 83 KB
>
> -----------------------
>
> GRASS version: 7.0.3RC1
> GRASS SVN Revision: 67443
> Build Date: 2015-12-31
> Build Platform: x86_64-w64-mingw32
> GDAL/OGR: 1.11.3
> PROJ.4: 4.9.2
> GEOS: 3.5.0
> SQLite: 3.7.17
> Python: 2.7.5
> wxPython: 2.8.12.1
> Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)
>
> -----------------------
>
> binary addon (r.stream.order)
>
> in GRASS:
>
> r.watershed elevation=elevation@PERMANENT threshold=10000
> accumulation=myaccum drainage=myflowdir stream=mystreams
> r.stream.order stream_rast=mystreams@rtestw64bit
> direction=myflowdir@rtestw64bit elevation=elevation@PERMANENT
> accumulation=myaccum@rtestw64bit strahler=mystrahler
>
> in R:
>
>> library(rgrass7)
> Loading required package: sp
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: GRASS 7.0.3RC1 (2015)
> and location: nc_spm_08_grass7
>
> execGRASS("r.watershed", elevation="elevation", threshold=10000,
> accumulation="myaccum", drainage="myflowdir", stream="mystreams")
>
>> execGRASS("r.watershed", elevation="elevation", threshold=10000,
>> accumulatio$ ...
> SECTION 1a (of 5): Initiating Memory.
> SECTION 1b (of 5): Determining Offmap Flow.
> 100%
> SECTION 2: A* Search.
> 100%
> SECTION 3a: Accumulating Surface Flow with MFD.
> 100%
> SECTION 3b: Adjusting drainage directions.
> 100%
> SECTION 4: Watershed determination.
> 100%
> SECTION 5: Closing Maps.
> 100%
>
> execGRASS("r.stream.order", stream_rast="mystreams", direction="myflowdir",
> elevation="elevation", accumulation="myaccum", strahler="mystrahler")
>
>> execGRASS("r.stream.order", stream_rast="mystreams",
>> direction="myflowdir", $ ...
> All in RAM calculation...
> Reading raster map <mystreams>...
> 100%
> Reading raster map <myflowdir>...
> 100%
> Finding nodes...
> Calculating Strahler's stream order...
> Writing output raster maps...
>
> -----------------------
>
> python addon (r.roughness.vector):
>
> in GRASS:
>
> r.slope.aspect elevation=elevation@PERMANENT slope=myslope aspect=myaspect
> r.roughness.vector elevation=elevation@PERMANENT slope=myslope@rtestw64bit
> aspect=myaspect@rtestw64bit strength=vectorstrength
>
> in R:
>
> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope",
> aspect="myaspect")
>
>> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope",
>> aspect="$
> 100%
> Aspect raster map <myaspect> complete
> Slope raster map <myslope> complete
>
> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope",
> aspect="myaspect", strength="vectorstrength")
>
>> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope",
>> aspe$
> Error in system(cmd0, intern = TRUE) : 'r.roughness.vector.exe' not found
> Error in parseGRASS(cmd, legacyExec = legacyExec) :
>  r.roughness.vector not found
>
> -----------------------
>
> python GRASS script (r.reclass.area):
>
> in GRASS:
>
> r.reclass.area input=zipcodes@PERMANENT output=zipcode_larger2000ha
> value=2000 mode=greater
>
> in R:
>
> execGRASS("r.reclass.area", input="zipcodes", output="zipcode_larger2000ha",
> value=2000, mode="greater")
>
>> execGRASS("r.reclass.area", input="zipcodes",
>> output="zipcode_larger2000ha",$
> Error in system(cmd0, intern = TRUE) : 'r.reclass.area.exe' not found
> Error in parseGRASS(cmd, legacyExec = legacyExec) :
>  r.reclass.area not found
>
> -----------------------
>
> in summary (tested in OSGeo4W-winGRASS):
>
> - binary addon (e.g. r.stream.order) is reckognized and can be run via
> execGRASS
> - python scripts (python GRASS GIS scripts e.g. r.reclass.area _and_ python
> addon scripts) aren't found; it seems it is searched for an .exe, in
> winGRASS these scripts are started by a related .bat-file.
>
>

Wrong target, please use:

http://win-builder.r-project.org/s90s00N7rhyt/rgrass7_0.1-4.zip

R-Forge builds nightly, Winbuilder builds on demand. The R-forge version
has now caught up, but you need to check the SVN revision number too. I
did provide the link to the R Winbuilder binary, but contributors should
download RTools an build their own Windows binaries if speed matters. I do
not use Windows, so I cannot check everything. We need more reports from
users installing the Winbuilder or R-forge rev. 46 binary.

Roger

>
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411p5244618.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
>Wrong target, please use:
>http://win-builder.r-project.org/s90s00N7rhyt/rgrass7_0.1-4.zip

> utils:::menuInstallLocal()
Paket ‘rgrass7’ erfolgreich ausgepackt und MD5 Summen abgeglichen

GRASS version: 7.1.svn                                                          
GRASS SVN revision: 67543                                                      
Build date: 2016-01-11                                                          
Build platform: x86_64-w64-mingw32                                              
GDAL: 1.11.3                                                                    
PROJ.4: 4.9.2                                                                  
GEOS: 3.5.0                                                                    
SQLite: 3.7.17                                                                  
Python: 2.7.5                                                                  
wxPython: 2.8.12.1                                                              
Platform: Windows-7-6.1.7601-SP1    

> library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.1.svn (2016)
and location: nc_spm_08_grass7

--------------
binary addon (r.stream.order)

> execGRASS("r.watershed", elevation="elevation", threshold=10000, accumulatio$
SECTION 1a (of 5): Initiating Memory.
SECTION 1b (of 5): Determining Offmap Flow.
 100%
SECTION 2: A* Search.
 100%
SECTION 3a: Accumulating Surface Flow with MFD.
 100%
SECTION 3b: Adjusting drainage directions.
 100%
SECTION 4: Watershed determination.
 100%
SECTION 5: Closing Maps.
 100%
>

> execGRASS("r.stream.order", stream_rast="mystreams", direction="myflowdir", $
All in RAM calculation...
Reading raster map <mystreams>...
 100%
Reading raster map <myflowdir>...
 100%
Finding nodes...
Calculating Strahler's stream order...
Writing output raster maps...
--------------
python addon (r.roughness.vector):

> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope", aspect="$
 100%
Aspect raster map <myaspect> complete
Slope raster map <myslope> complete

> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope", aspe$
Error in system(cmd0, intern = TRUE) : 'r.roughness.vector.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) :
  r.roughness.vector not found
--------------
python GRASS script (r.reclass.area):

> execGRASS("r.reclass.area", input="zipcodes", output="zipcode_larger2000ha",$
Error in system(cmd0, intern = TRUE) : 'r.reclass.area.exe' not found
Error in parseGRASS(cmd, legacyExec = legacyExec) :
  r.reclass.area not found
--------------

it seems to be the same behaviour:

binary addons (exe living in e.g. C:\Users\xy\AppData\Roaming\GRASS7\addons\bin) are found.
python scripts (with related bat-files in e.g. C:\Users\xy\AppData\Roaming\GRASS7\addons\bin or in e.g. C:\Program Files\GRASS GIS 7.1.svn\bin) are not found as it is searched for e.g. r.reclass.area.exe (see above).
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
On Tue, 12 Jan 2016, Helmut Kudrnovsky wrote:

>> Wrong target, please use:
>> http://win-builder.r-project.org/s90s00N7rhyt/rgrass7_0.1-4.zip
>

OK. Please check that r.roughness.vector.bat is present in:

C:\Users\xy\AppData\Roaming\GRASS7\addons\bin, or
C:\Program Files\GRASS GIS 7.1.svn\bin

Possibly run

debug(parseGRASS)
parseGRASS("r.roughness.vector")

and check that its *.bat file is present in WN_bat under debugging. I'll
try it too.

The revisions add *.bat from local addons to the global list of *.bat, but
something may have got lost - it worked for me for r.basin.

Roger


>> utils:::menuInstallLocal()
> Paket ‘rgrass7’ erfolgreich ausgepackt und MD5 Summen abgeglichen
>
> GRASS version: 7.1.svn
> GRASS SVN revision: 67543
> Build date: 2016-01-11
> Build platform: x86_64-w64-mingw32
> GDAL: 1.11.3
> PROJ.4: 4.9.2
> GEOS: 3.5.0
> SQLite: 3.7.17
> Python: 2.7.5
> wxPython: 2.8.12.1
> Platform: Windows-7-6.1.7601-SP1
>
>> library(rgrass7)
> Loading required package: sp
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: GRASS 7.1.svn (2016)
> and location: nc_spm_08_grass7
>
> --------------
> binary addon (r.stream.order)
>
>> execGRASS("r.watershed", elevation="elevation", threshold=10000,
>> accumulatio$
> SECTION 1a (of 5): Initiating Memory.
> SECTION 1b (of 5): Determining Offmap Flow.
> 100%
> SECTION 2: A* Search.
> 100%
> SECTION 3a: Accumulating Surface Flow with MFD.
> 100%
> SECTION 3b: Adjusting drainage directions.
> 100%
> SECTION 4: Watershed determination.
> 100%
> SECTION 5: Closing Maps.
> 100%
>>
>
>> execGRASS("r.stream.order", stream_rast="mystreams",
>> direction="myflowdir", $
> All in RAM calculation...
> Reading raster map <mystreams>...
> 100%
> Reading raster map <myflowdir>...
> 100%
> Finding nodes...
> Calculating Strahler's stream order...
> Writing output raster maps...
> --------------
> python addon (r.roughness.vector):
>
>> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope",
>> aspect="$
> 100%
> Aspect raster map <myaspect> complete
> Slope raster map <myslope> complete
>
>> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope",
>> aspe$
> Error in system(cmd0, intern = TRUE) : 'r.roughness.vector.exe' not found
> Error in parseGRASS(cmd, legacyExec = legacyExec) :
>  r.roughness.vector not found
> --------------
> python GRASS script (r.reclass.area):
>
>> execGRASS("r.reclass.area", input="zipcodes",
>> output="zipcode_larger2000ha",$
> Error in system(cmd0, intern = TRUE) : 'r.reclass.area.exe' not found
> Error in parseGRASS(cmd, legacyExec = legacyExec) :
>  r.reclass.area not found
> --------------
>
> it seems to be the same behaviour:
>
> binary addons (exe living in e.g.
> C:\Users\xy\AppData\Roaming\GRASS7\addons\bin) are found.
> python scripts (with related bat-files in e.g.
> C:\Users\xy\AppData\Roaming\GRASS7\addons\bin or in e.g. C:\Program
> Files\GRASS GIS 7.1.svn\bin) are not found as it is searched for e.g.
> r.reclass.area.exe (see above).
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411p5244654.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
>OK. Please check that r.roughness.vector.bat is present in:
>
>C:\Users\xy\AppData\Roaming\GRASS7\addons\bin, or
>C:\Program Files\GRASS GIS 7.1.svn\bin

it is in the addon path: C:\Users\xxx\AppData\Roaming\GRASS7\addons\bin

it works in winGRASS itself.

r.roughness.vector elevation=elevation@PERMANENT slope=slope@rtestw64bit aspect=aspect@rtestw64bit
----
Check if input files exist ...
----
Define default output names when not defined by user ...
----
Calculate compass aspect values ...
----
Calculate colatitude ...
----
Calculate direction cosines ...
----
Calculate sum of direction cosines ...
Calculating sum of X direction cosines ...
Calculating sum of Y direction cosines ...
Calculating sum of Z direction cosines ...
----
Calculate vector strength ...
----
Calculate inverted Fisher's K parameter ...
----
Result maps:
elevation_vector_strength_3x3
elevation_fisher_1K_3x3
Calculations done.
----
(Tue Jan 12 10:41:00 2016) Command finished (1 min 18 sec)  

xml1.R

"            WN_bat <- sub(".bat", "",
                list.files(paste(Sys.getenv("GISBASE"), "bin", sep="/"),
                pattern=".bat$"))
            if (nchar(Sys.getenv("GRASS_ADDON_BASE")) > 0) {
                t0 <- try(sub(".bat", "",
                   list.files(paste(Sys.getenv("GRASS_ADDON_BASE"),
                       "bin", sep="/"), pattern=".bat$")), silent=TRUE)
                if (class(t0) != "try-error" && is.character(t0) &&
                   nchar(t0) > 0)
                   WN_bat <- c(WN_bat, t0)
                assign("WN_bat", WN_bat, envir=.GRASS_CACHE)
            }"

do it manually:

WN_bat <- sub(".bat", "", list.files(paste(Sys.getenv("GISBASE"), "bin", sep="/"), pattern=".bat$"))
> WN_bat
  [1] "d.correlate"          "d.frame"              "d.out.file"
  [4] "d.polar"              "d.rast.edit"          "d.rast.leg"
  [7] "d.redraw"             "d.shade"              "d.to.rast"
 [10] "d.what.rast"          "d.what.vect"          "db.dropcolumn"
 [13] "db.droptable"         "db.in.ogr"            "db.out.ogr"
 [16] "db.test"              "db.univar"            "g.extension.all"
 [19] "g.extension"          "g.gui.animation"      "g.gui.datacatalog"
 [22] "g.gui.dbmgr"          "g.gui.gcp"            "g.gui.gmodeler"
 [25] "g.gui.iclass"         "g.gui.mapswipe"       "g.gui.psmap"
 [28] "g.gui.rlisetup"       "g.gui.timeline"       "g.gui.tplot"
 [31] "g.gui.vdigit"         "g.manual"             "g.search.modules"
 [34] "i.colors.enhance"     "i.image.mosaic"       "i.in.spotvgt"
 [37] "i.oif"                "i.pansharpen"         "i.spectral"
 [40] "i.tasscap"            "m.proj"               "r.blend"
 [43] "r.buffer.lowmem"      "r.colors.stddev"      "r.fillnulls"
 [46] "r.grow"               "r.import"             "r.in.aster"
 [49] "r.in.srtm"            "r.in.wms"             "r.mask"
 [52] "r.out.xyz"            "r.pack"               "r.plane"
 [55] "r.reclass.area"       "r.rgb"                "r.shade"
 [58] "r.tileset"            "r.unpack"             "r3.in.xyz"
 [61] "t.create"             "t.info"               "t.list"
 [64] "t.merge"              "t.rast.accdetect"     "t.rast.accumulate"
 [67] "t.rast.aggregate"     "t.rast.aggregate.ds"  "t.rast.algebra"
 [70] "t.rast.colors"        "t.rast.contour"       "t.rast.export"
 [73] "t.rast.extract"       "t.rast.gapfill"       "t.rast.import"
 [76] "t.rast.list"          "t.rast.mapcalc"       "t.rast.neighbors"
 [79] "t.rast.out.vtk"       "t.rast.series"        "t.rast.to.rast3"
 [82] "t.rast.to.vect"       "t.rast.univar"        "t.rast.what"
 [85] "t.rast3d.algebra"     "t.rast3d.extract"     "t.rast3d.list"
 [88] "t.rast3d.mapcalc"     "t.rast3d.univar"      "t.register"
 [91] "t.remove"             "t.rename"             "t.sample"
 [94] "t.select"             "t.shift"              "t.snap"
 [97] "t.support"            "t.topology"           "t.unregister"
[100] "t.vect.algebra"       "t.vect.db.select"     "t.vect.export"
[103] "t.vect.extract"       "t.vect.import"        "t.vect.list"
[106] "t.vect.observe.strds" "t.vect.univar"        "t.vect.what.strds"
[109] "v.build.all"          "v.centroids"          "v.db.addcolumn"
[112] "v.db.addtable"        "v.db.dropcolumn"      "v.db.droprow"
[115] "v.db.droptable"       "v.db.join"            "v.db.reconnect.all"
[118] "v.db.renamecolumn"    "v.db.univar"          "v.db.update"
[121] "v.dissolve"           "v.import"             "v.in.e00"
[124] "v.in.geonames"        "v.in.lines"           "v.in.mapgen"
[127] "v.in.wfs"             "v.krige"              "v.pack"
[130] "v.rast.stats"         "v.report"             "v.to.lines"
[133] "v.unpack"             "v.what.strds"         "v.what.vect"
[136] "wxpyimgview"
t0 <- sub(".bat", "", list.files(paste(Sys.getenv("GRASS_ADDON_BASE"), "bin", sep="/"), pattern=".bat$"))
> t0
 [1] "m.ecad"                "r.basin"               "r.biodiversity"
 [4] "r.euroeco"             "r.hypso"               "r.roughness.vector"
 [7] "r.sun.daily"           "r.sun.hourly"          "r.width.funct"
[10] "v.fixed.segmentpoints" "v.in.gbif"             "v.in.natura2000"
[13] "v.in.redlist"          "v.stats"
> WN_bat <- c(WN_bat, t0)
> WN_bat
  [1] "d.correlate"           "d.frame"               "d.out.file"
  [4] "d.polar"               "d.rast.edit"           "d.rast.leg"
  [7] "d.redraw"              "d.shade"               "d.to.rast"
 [10] "d.what.rast"           "d.what.vect"           "db.dropcolumn"
 [13] "db.droptable"          "db.in.ogr"             "db.out.ogr"
 [16] "db.test"               "db.univar"             "g.extension.all"
 [19] "g.extension"           "g.gui.animation"       "g.gui.datacatalog"
 [22] "g.gui.dbmgr"           "g.gui.gcp"             "g.gui.gmodeler"
 [25] "g.gui.iclass"          "g.gui.mapswipe"        "g.gui.psmap"
 [28] "g.gui.rlisetup"        "g.gui.timeline"        "g.gui.tplot"
 [31] "g.gui.vdigit"          "g.manual"              "g.search.modules"
 [34] "i.colors.enhance"      "i.image.mosaic"        "i.in.spotvgt"
 [37] "i.oif"                 "i.pansharpen"          "i.spectral"
 [40] "i.tasscap"             "m.proj"                "r.blend"
 [43] "r.buffer.lowmem"       "r.colors.stddev"       "r.fillnulls"
 [46] "r.grow"                "r.import"              "r.in.aster"
 [49] "r.in.srtm"             "r.in.wms"              "r.mask"
 [52] "r.out.xyz"             "r.pack"                "r.plane"
 [55] "r.reclass.area"        "r.rgb"                 "r.shade"
 [58] "r.tileset"             "r.unpack"              "r3.in.xyz"
 [61] "t.create"              "t.info"                "t.list"
 [64] "t.merge"               "t.rast.accdetect"      "t.rast.accumulate"
 [67] "t.rast.aggregate"      "t.rast.aggregate.ds"   "t.rast.algebra"
 [70] "t.rast.colors"         "t.rast.contour"        "t.rast.export"
 [73] "t.rast.extract"        "t.rast.gapfill"        "t.rast.import"
 [76] "t.rast.list"           "t.rast.mapcalc"        "t.rast.neighbors"
 [79] "t.rast.out.vtk"        "t.rast.series"         "t.rast.to.rast3"
 [82] "t.rast.to.vect"        "t.rast.univar"         "t.rast.what"
 [85] "t.rast3d.algebra"      "t.rast3d.extract"      "t.rast3d.list"
 [88] "t.rast3d.mapcalc"      "t.rast3d.univar"       "t.register"
 [91] "t.remove"              "t.rename"              "t.sample"
 [94] "t.select"              "t.shift"               "t.snap"
 [97] "t.support"             "t.topology"            "t.unregister"
[100] "t.vect.algebra"        "t.vect.db.select"      "t.vect.export"
[103] "t.vect.extract"        "t.vect.import"         "t.vect.list"
[106] "t.vect.observe.strds"  "t.vect.univar"         "t.vect.what.strds"
[109] "v.build.all"           "v.centroids"           "v.db.addcolumn"
[112] "v.db.addtable"         "v.db.dropcolumn"       "v.db.droprow"
[115] "v.db.droptable"        "v.db.join"             "v.db.reconnect.all"
[118] "v.db.renamecolumn"     "v.db.univar"           "v.db.update"
[121] "v.dissolve"            "v.import"              "v.in.e00"
[124] "v.in.geonames"         "v.in.lines"            "v.in.mapgen"
[127] "v.in.wfs"              "v.krige"               "v.pack"
[130] "v.rast.stats"          "v.report"              "v.to.lines"
[133] "v.unpack"              "v.what.strds"          "v.what.vect"
[136] "wxpyimgview"           "m.ecad"                "r.basin"
[139] "r.biodiversity"        "r.euroeco"             "r.hypso"
[142] "r.roughness.vector"    "r.sun.daily"           "r.sun.hourly"
[145] "r.width.funct"         "v.fixed.segmentpoints" "v.in.gbif"
[148] "v.in.natura2000"       "v.in.redlist"          "v.stats"
>

r.roughness.vector is in the list of the script related bat-files.

>Possibly run
>
>debug(parseGRASS)
>parseGRASS("r.roughness.vector")

debug.txt attached.

the last lines of debug:

Browse[2]>
debug: tr <- try(system(cmd0, intern = TRUE))
Browse[2]>
Error in system(cmd0, intern = TRUE) : 'r.roughness.vector.exe' not found
debug: if (class(tr) == "try-error") stop(paste(cmd, "not found"))
Browse[2]>
Browse[2]>
debug: stop(paste(cmd, "not found"))
Browse[2]>
Browse[2]>
Error in parseGRASS("r.roughness.vector") : r.roughness.vector not found
>

here on my side for addon scripts but also for GRASS own scripts it seems to append an .exe instead of .bat (see above); but I can't find this in the rgarss7 code.
best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
On Tue, 12 Jan 2016, Helmut Kudrnovsky wrote:

>> OK. Please check that r.roughness.vector.bat is present in:
>>
>> C:\Users\xy\AppData\Roaming\GRASS7\addons\bin, or
>> C:\Program Files\GRASS GIS 7.1.svn\bin
>
> it is in the addon path: C:\Users\xxx\AppData\Roaming\GRASS7\addons\bin
>
> it works in winGRASS itself.
>
> r.roughness.vector elevation=elevation@PERMANENT slope=slope@rtestw64bit
> aspect=aspect@rtestw64bit
> ----
> Check if input files exist ...
> ----
> Define default output names when not defined by user ...
> ----
> Calculate compass aspect values ...
> ----
> Calculate colatitude ...
> ----
> Calculate direction cosines ...
> ----
> Calculate sum of direction cosines ...
> Calculating sum of X direction cosines ...
> Calculating sum of Y direction cosines ...
> Calculating sum of Z direction cosines ...
> ----
> Calculate vector strength ...
> ----
> Calculate inverted Fisher's K parameter ...
> ----
> Result maps:
> elevation_vector_strength_3x3
> elevation_fisher_1K_3x3
> Calculations done.
> ----
> (Tue Jan 12 10:41:00 2016) Command finished (1 min 18 sec)
>
> xml1.R

Typo in:

         if (get("SYS", envir=.GRASS_CACHE) == "WinNat" && nchar(WN_bat)) {

should be

         if (get("SYS", envir=.GRASS_CACHE) == "WinNat"
             && nchar(WN_bat) == 0) {

With this r.roughness.vector is found correctly with the *.bat extension,
for me anyway. The fresh Windows binary package from Winbuilder is here:

http://win-builder.r-project.org/bEws3GQ47oph/rgrass7_0.1-4.zip

This version has broken vector file exchange (problems removing temporary
files on Windows - work in progress), so is not yet ready for submission
to CRAN, but as the problems do not interact, it can be used to check the
correct running of parseGRASS(), doGRASS() and execGRASS() for addons on
Windows. Thanks for your patience!

Best wishes,

Roger

>
> "            WN_bat <- sub(".bat", "",
>                list.files(paste(Sys.getenv("GISBASE"), "bin", sep="/"),
>                pattern=".bat$"))
>            if (nchar(Sys.getenv("GRASS_ADDON_BASE")) > 0) {
>                t0 <- try(sub(".bat", "",
>                   list.files(paste(Sys.getenv("GRASS_ADDON_BASE"),
>                       "bin", sep="/"), pattern=".bat$")), silent=TRUE)
>                if (class(t0) != "try-error" && is.character(t0) &&
>                   nchar(t0) > 0)
>                   WN_bat <- c(WN_bat, t0)
>                assign("WN_bat", WN_bat, envir=.GRASS_CACHE)
>            }"
>
> do it manually:
>
> WN_bat <- sub(".bat", "", list.files(paste(Sys.getenv("GISBASE"), "bin",
> sep="/"), pattern=".bat$"))
>> WN_bat
>  [1] "d.correlate"          "d.frame"              "d.out.file"
>  [4] "d.polar"              "d.rast.edit"          "d.rast.leg"
>  [7] "d.redraw"             "d.shade"              "d.to.rast"
> [10] "d.what.rast"          "d.what.vect"          "db.dropcolumn"
> [13] "db.droptable"         "db.in.ogr"            "db.out.ogr"
> [16] "db.test"              "db.univar"            "g.extension.all"
> [19] "g.extension"          "g.gui.animation"      "g.gui.datacatalog"
> [22] "g.gui.dbmgr"          "g.gui.gcp"            "g.gui.gmodeler"
> [25] "g.gui.iclass"         "g.gui.mapswipe"       "g.gui.psmap"
> [28] "g.gui.rlisetup"       "g.gui.timeline"       "g.gui.tplot"
> [31] "g.gui.vdigit"         "g.manual"             "g.search.modules"
> [34] "i.colors.enhance"     "i.image.mosaic"       "i.in.spotvgt"
> [37] "i.oif"                "i.pansharpen"         "i.spectral"
> [40] "i.tasscap"            "m.proj"               "r.blend"
> [43] "r.buffer.lowmem"      "r.colors.stddev"      "r.fillnulls"
> [46] "r.grow"               "r.import"             "r.in.aster"
> [49] "r.in.srtm"            "r.in.wms"             "r.mask"
> [52] "r.out.xyz"            "r.pack"               "r.plane"
> [55] "r.reclass.area"       "r.rgb"                "r.shade"
> [58] "r.tileset"            "r.unpack"             "r3.in.xyz"
> [61] "t.create"             "t.info"               "t.list"
> [64] "t.merge"              "t.rast.accdetect"     "t.rast.accumulate"
> [67] "t.rast.aggregate"     "t.rast.aggregate.ds"  "t.rast.algebra"
> [70] "t.rast.colors"        "t.rast.contour"       "t.rast.export"
> [73] "t.rast.extract"       "t.rast.gapfill"       "t.rast.import"
> [76] "t.rast.list"          "t.rast.mapcalc"       "t.rast.neighbors"
> [79] "t.rast.out.vtk"       "t.rast.series"        "t.rast.to.rast3"
> [82] "t.rast.to.vect"       "t.rast.univar"        "t.rast.what"
> [85] "t.rast3d.algebra"     "t.rast3d.extract"     "t.rast3d.list"
> [88] "t.rast3d.mapcalc"     "t.rast3d.univar"      "t.register"
> [91] "t.remove"             "t.rename"             "t.sample"
> [94] "t.select"             "t.shift"              "t.snap"
> [97] "t.support"            "t.topology"           "t.unregister"
> [100] "t.vect.algebra"       "t.vect.db.select"     "t.vect.export"
> [103] "t.vect.extract"       "t.vect.import"        "t.vect.list"
> [106] "t.vect.observe.strds" "t.vect.univar"        "t.vect.what.strds"
> [109] "v.build.all"          "v.centroids"          "v.db.addcolumn"
> [112] "v.db.addtable"        "v.db.dropcolumn"      "v.db.droprow"
> [115] "v.db.droptable"       "v.db.join"            "v.db.reconnect.all"
> [118] "v.db.renamecolumn"    "v.db.univar"          "v.db.update"
> [121] "v.dissolve"           "v.import"             "v.in.e00"
> [124] "v.in.geonames"        "v.in.lines"           "v.in.mapgen"
> [127] "v.in.wfs"             "v.krige"              "v.pack"
> [130] "v.rast.stats"         "v.report"             "v.to.lines"
> [133] "v.unpack"             "v.what.strds"         "v.what.vect"
> [136] "wxpyimgview"
> t0 <- sub(".bat", "", list.files(paste(Sys.getenv("GRASS_ADDON_BASE"),
> "bin", sep="/"), pattern=".bat$"))
>> t0
> [1] "m.ecad"                "r.basin"               "r.biodiversity"
> [4] "r.euroeco"             "r.hypso"               "r.roughness.vector"
> [7] "r.sun.daily"           "r.sun.hourly"          "r.width.funct"
> [10] "v.fixed.segmentpoints" "v.in.gbif"             "v.in.natura2000"
> [13] "v.in.redlist"          "v.stats"
>> WN_bat <- c(WN_bat, t0)
>> WN_bat
>  [1] "d.correlate"           "d.frame"               "d.out.file"
>  [4] "d.polar"               "d.rast.edit"           "d.rast.leg"
>  [7] "d.redraw"              "d.shade"               "d.to.rast"
> [10] "d.what.rast"           "d.what.vect"           "db.dropcolumn"
> [13] "db.droptable"          "db.in.ogr"             "db.out.ogr"
> [16] "db.test"               "db.univar"             "g.extension.all"
> [19] "g.extension"           "g.gui.animation"       "g.gui.datacatalog"
> [22] "g.gui.dbmgr"           "g.gui.gcp"             "g.gui.gmodeler"
> [25] "g.gui.iclass"          "g.gui.mapswipe"        "g.gui.psmap"
> [28] "g.gui.rlisetup"        "g.gui.timeline"        "g.gui.tplot"
> [31] "g.gui.vdigit"          "g.manual"              "g.search.modules"
> [34] "i.colors.enhance"      "i.image.mosaic"        "i.in.spotvgt"
> [37] "i.oif"                 "i.pansharpen"          "i.spectral"
> [40] "i.tasscap"             "m.proj"                "r.blend"
> [43] "r.buffer.lowmem"       "r.colors.stddev"       "r.fillnulls"
> [46] "r.grow"                "r.import"              "r.in.aster"
> [49] "r.in.srtm"             "r.in.wms"              "r.mask"
> [52] "r.out.xyz"             "r.pack"                "r.plane"
> [55] "r.reclass.area"        "r.rgb"                 "r.shade"
> [58] "r.tileset"             "r.unpack"              "r3.in.xyz"
> [61] "t.create"              "t.info"                "t.list"
> [64] "t.merge"               "t.rast.accdetect"      "t.rast.accumulate"
> [67] "t.rast.aggregate"      "t.rast.aggregate.ds"   "t.rast.algebra"
> [70] "t.rast.colors"         "t.rast.contour"        "t.rast.export"
> [73] "t.rast.extract"        "t.rast.gapfill"        "t.rast.import"
> [76] "t.rast.list"           "t.rast.mapcalc"        "t.rast.neighbors"
> [79] "t.rast.out.vtk"        "t.rast.series"         "t.rast.to.rast3"
> [82] "t.rast.to.vect"        "t.rast.univar"         "t.rast.what"
> [85] "t.rast3d.algebra"      "t.rast3d.extract"      "t.rast3d.list"
> [88] "t.rast3d.mapcalc"      "t.rast3d.univar"       "t.register"
> [91] "t.remove"              "t.rename"              "t.sample"
> [94] "t.select"              "t.shift"               "t.snap"
> [97] "t.support"             "t.topology"            "t.unregister"
> [100] "t.vect.algebra"        "t.vect.db.select"      "t.vect.export"
> [103] "t.vect.extract"        "t.vect.import"         "t.vect.list"
> [106] "t.vect.observe.strds"  "t.vect.univar"         "t.vect.what.strds"
> [109] "v.build.all"           "v.centroids"           "v.db.addcolumn"
> [112] "v.db.addtable"         "v.db.dropcolumn"       "v.db.droprow"
> [115] "v.db.droptable"        "v.db.join"             "v.db.reconnect.all"
> [118] "v.db.renamecolumn"     "v.db.univar"           "v.db.update"
> [121] "v.dissolve"            "v.import"              "v.in.e00"
> [124] "v.in.geonames"         "v.in.lines"            "v.in.mapgen"
> [127] "v.in.wfs"              "v.krige"               "v.pack"
> [130] "v.rast.stats"          "v.report"              "v.to.lines"
> [133] "v.unpack"              "v.what.strds"          "v.what.vect"
> [136] "wxpyimgview"           "m.ecad"                "r.basin"
> [139] "r.biodiversity"        "r.euroeco"             "r.hypso"
> [142] "r.roughness.vector"    "r.sun.daily"           "r.sun.hourly"
> [145] "r.width.funct"         "v.fixed.segmentpoints" "v.in.gbif"
> [148] "v.in.natura2000"       "v.in.redlist"          "v.stats"
>>
>
> r.roughness.vector is in the list of the script related bat-files.
>
>> Possibly run
>>
>> debug(parseGRASS)
>> parseGRASS("r.roughness.vector")
>
> debug.txt <http://osgeo-org.1560.x6.nabble.com/file/n5244663/debug.txt>
> attached.
>
> the last lines of debug:
>
> Browse[2]>
> debug: tr <- try(system(cmd0, intern = TRUE))
> Browse[2]>
> Error in system(cmd0, intern = TRUE) : 'r.roughness.vector.exe' not found
> debug: if (class(tr) == "try-error") stop(paste(cmd, "not found"))
> Browse[2]>
> Browse[2]>
> debug: stop(paste(cmd, "not found"))
> Browse[2]>
> Browse[2]>
> Error in parseGRASS("r.roughness.vector") : r.roughness.vector not found
>>
>
> here on my side for addon scripts but also for GRASS own scripts it seems to
> append an .exe instead of .bat (see above); but I can't find this in the
> rgarss7 code.
>
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411p5244663.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Helmut Kudrnovsky
>> xml1.R
>
>Typo in:
>
>         if (get("SYS", envir=.GRASS_CACHE) == "WinNat" && nchar(WN_bat)) {
>
>should be
>
>         if (get("SYS", envir=.GRASS_CACHE) == "WinNat"
>            && nchar(WN_bat) == 0) {
>
>With this r.roughness.vector is found correctly with the *.bat extension,
>for me anyway. The fresh Windows binary package from Winbuilder is here:
>
>http://win-builder.r-project.org/bEws3GQ47oph/rgrass7_0.1-4.zip

-----------------------------------
> utils:::menuInstallLocal()
Paket ‘rgrass7’ erfolgreich ausgepackt und MD5 Summen abgeglichen

> library(rgrass7)
Loading required package: sp
Loading required package: XML
GRASS GIS interface loaded with GRASS version: GRASS 7.1.svn (2016)
and location: nc_spm_08_grass7
-----------------------------------
> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope", aspect="$
 100%
Aspect raster map <myaspect> complete
Slope raster map <myslope> complete

> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope", aspe$
----
Check if input files exist ...
----
Define default output names when not defined by user ...
----
Calculate compass aspect values ...
 100%
----
Calculate colatitude ...
 100%
----
Calculate direction cosines ...
 100%
 100%
 100%
----
Calculate sum of direction cosines ...
Calculating sum of X direction cosines ...
 100%
Calculating sum of Y direction cosines ...
 100%
Calculating sum of Z direction cosines ...
 100%
----
Calculate vector strength ...
 100%
----
Calculate inverted Fisher's K parameter ...
 100%
----
Result maps:
vectorstrength
elevation_fisher_1K_3x3
Calculations done.
----
>
-----------------------------------
> execGRASS("r.reclass.area", input="zipcodes", output="zipcode_larger2000ha",$
Generating a clumped raster file ...
Pass 1 of 2...
 100%
Generating renumbering scheme...
 100%
Pass 2 of 2...
 100%
r.clump complete. 16 clumps.
Generating a reclass map with area size greater than or equal to
2000.000000 hectares...
 100%
 100%
Generating output raster map <zipcode_larger2000ha>...
-----------------------------------

confirmed, it works now.

great, thanks!

best regards
Helmut
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
On Tue, 12 Jan 2016, Helmut Kudrnovsky wrote:

>>> xml1.R
>>
>> Typo in:
>>
>>         if (get("SYS", envir=.GRASS_CACHE) == "WinNat" && nchar(WN_bat)) {
>>
>> should be
>>
>>         if (get("SYS", envir=.GRASS_CACHE) == "WinNat"
>>            && nchar(WN_bat) == 0) {
>>
>> With this r.roughness.vector is found correctly with the *.bat extension,
>> for me anyway. The fresh Windows binary package from Winbuilder is here:
>>
>> http://win-builder.r-project.org/bEws3GQ47oph/rgrass7_0.1-4.zip
>
> -----------------------------------
>> utils:::menuInstallLocal()
> Paket ‘rgrass7’ erfolgreich ausgepackt und MD5 Summen abgeglichen
>
>> library(rgrass7)
> Loading required package: sp
> Loading required package: XML
> GRASS GIS interface loaded with GRASS version: GRASS 7.1.svn (2016)
> and location: nc_spm_08_grass7
> -----------------------------------
>> execGRASS("r.slope.aspect", elevation="elevation", slope="myslope",
>> aspect="$
> 100%
> Aspect raster map <myaspect> complete
> Slope raster map <myslope> complete
>
>> execGRASS("r.roughness.vector", elevation="elevation", slope="myslope",
>> aspe$
> ----
> Check if input files exist ...
> ----
> Define default output names when not defined by user ...
> ----
> Calculate compass aspect values ...
> 100%
> ----
> Calculate colatitude ...
> 100%
> ----
> Calculate direction cosines ...
> 100%
> 100%
> 100%
> ----
> Calculate sum of direction cosines ...
> Calculating sum of X direction cosines ...
> 100%
> Calculating sum of Y direction cosines ...
> 100%
> Calculating sum of Z direction cosines ...
> 100%
> ----
> Calculate vector strength ...
> 100%
> ----
> Calculate inverted Fisher's K parameter ...
> 100%
> ----
> Result maps:
> vectorstrength
> elevation_fisher_1K_3x3
> Calculations done.
> ----
>>
> -----------------------------------
>> execGRASS("r.reclass.area", input="zipcodes",
>> output="zipcode_larger2000ha",$
> Generating a clumped raster file ...
> Pass 1 of 2...
> 100%
> Generating renumbering scheme...
> 100%
> Pass 2 of 2...
> 100%
> r.clump complete. 16 clumps.
> Generating a reclass map with area size greater than or equal to
> 2000.000000 hectares...
> 100%
> 100%
> Generating output raster map <zipcode_larger2000ha>...
> -----------------------------------
>
> confirmed, it works now.
>
> great, thanks!
>
OK, thanks, as I've also made progress on the other problem (using
temporary SQLite files for vector transfer under Windows), I've submitted
to CRAN. Anyone who installed the 0.1-4 versions for testing will need to
install the CRAN version when/if it appears.

Roger

>
>
>
>
> -----
> best regards
> Helmut
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GRASS-addons-in-R-on-Windows-tp5244411p5244769.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> [hidden email]
> http://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; fax +47 55 95 91 00
e-mail: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Markus Neteler
On Tue, Jan 12, 2016 at 8:24 PM, Roger Bivand <[hidden email]> wrote:
> On Tue, 12 Jan 2016, Helmut Kudrnovsky wrote:
>> confirmed, it works now.
>> great, thanks!
>>
> OK, thanks, as I've also made progress on the other problem (using temporary
> SQLite files for vector transfer under Windows), I've submitted to CRAN.
> Anyone who installed the 0.1-4 versions for testing will need to install the
> CRAN version when/if it appears.

That's great, thanks for discovering and solving!

Markus
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Reply | Threaded
Open this post in threaded view
|

Re: Using GRASS addons in R on Windows

Roger Bivand
On Tue, 12 Jan 2016, Markus Neteler wrote:

> On Tue, Jan 12, 2016 at 8:24 PM, Roger Bivand <[hidden email]> wrote:
>> On Tue, 12 Jan 2016, Helmut Kudrnovsky wrote:
>>> confirmed, it works now.
>>> great, thanks!
>>>
>> OK, thanks, as I've also made progress on the other problem (using temporary
>> SQLite files for vector transfer under Windows), I've submitted to CRAN.
>> Anyone who installed the 0.1-4 versions for testing will need to install the
>> CRAN version when/if it appears.
>
> That's great, thanks for discovering and solving!

On CRAN now (source package), Windows binary will follow. Thanks for help
in checking - if the *.py scripts all have *.bat in the locations checked,
they should be found.

Does the order of the system and user bin folders matter? Should we care
if the addons are duplicated?

Best wishes,

Roger

>
> Markus
>

--
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: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
NHH Norwegian School of Economics, Bergen, Norway
12