[GRASS-user] v.class.mlR Error

Helmut Kudrnovsky hellik at web.de
Thu May 31 02:47:05 PDT 2018


>Here's a complete working example of the entire OBIA chain in the NC
>dataset (warning: this is a demo example, not necessarily one of best
>practice ;-)) :

thanks, testing it here now.

https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py#L278

278	    install_package = "if(!is.element('%s',
installed.packages()[,1])){\n"
279	    install_package += "cat('\\n\\nInstalling %s package from
CRAN\n')\n"
280	    install_package += "if(!file.exists(Sys.getenv('R_LIBS_USER'))){\n"
281	    install_package += "dir.create(Sys.getenv('R_LIBS_USER'),
recursive=TRUE)\n"
282	    install_package += ".libPaths(Sys.getenv('R_LIBS_USER'))}\n"
283	    install_package += "chooseCRANmirror(ind=1)\n"
284	    install_package += "install.packages('%s', dependencies=TRUE)}"

for installling packages in windows R:

https://cran.r-project.org/bin/windows/base/rw-FAQ.html#I-don_0027t-have-permission-to-write-to-the-R_002d3_002e5_002e0_005clibrary-directory

for installing system wide in windows administrator rights are needed. maybe
some possible source of troubles.

so maybe a recommendation in the manual?: let the user install the needed
packages first in R itself, then start the grass addon.

addon test here shows:

-----------------
v.class.mlR --verbose segments_map=lsat7_segs_stats training_map=training
train_class_colum=class
Running R now. Following output is R output.
Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
There were 50 or more warnings (use warnings() to see the first 50)
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
Calls: write.csv -> eval.parent -> eval -> eval -> write.table -> file
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file '.gscript_tmp_model_output_1300.csv': Permission denied
Execution halted
ERROR: There was an error in the execution of the R script.
Please check the R output.
-----------------

it seems, R is started, packages loaded correctly.

where is  the file '.gscript_tmp_model_output_1300.csv' written to?


485	    if allmap and not flags['f']:
486	        model_output = '.gscript_tmp_model_output_%d.csv' % os.getpid()
487	        write_string = "write.csv(resultsdf, '%s'," % model_output
488	        write_string += " row.names=FALSE, quote=FALSE)"
489	        r_file.write(write_string)
490	        r_file.write("\n")

would it be possible to catch the R error/output?



-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html


More information about the grass-user mailing list