[GRASS-stats] Using GRASS addons in R on Windows

Roger Bivand Roger.Bivand at nhh.no
Tue Jan 12 06:18:59 PST 2016


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 at PERMANENT slope=slope at rtestw64bit
> aspect=aspect at 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
> grass-stats at lists.osgeo.org
> 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: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412


More information about the grass-stats mailing list