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

Helmut Kudrnovsky hellik at web.de
Mon Jan 11 12:33:14 PST 2016


>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 at PERMANENT threshold=10000
accumulation=myaccum drainage=myflowdir stream=mystreams
r.stream.order stream_rast=mystreams at rtestw64bit
direction=myflowdir at rtestw64bit elevation=elevation at PERMANENT
accumulation=myaccum at 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 at PERMANENT slope=myslope aspect=myaspect 
r.roughness.vector elevation=elevation at PERMANENT slope=myslope at rtestw64bit
aspect=myaspect at 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 at 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
--
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.


More information about the grass-stats mailing list