[GRASS-SVN] r72757 - grass-addons/grass7/vector/v.class.mlR
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jun 1 00:17:09 PDT 2018
Author: mlennert
Date: 2018-06-01 00:17:09 -0700 (Fri, 01 Jun 2018)
New Revision: 72757
Modified:
grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py
Log:
v.class.mlR: don't hard code tempfile name, use tempfile()
Modified: grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py
===================================================================
--- grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py 2018-06-01 03:40:46 UTC (rev 72756)
+++ grass-addons/grass7/vector/v.class.mlR/v.class.mlR.py 2018-06-01 07:17:09 UTC (rev 72757)
@@ -233,8 +233,8 @@
gscript.try_remove(feature_vars)
if trainmap:
gscript.try_remove(training_vars)
- gscript.try_remove(model_output)
- gscript.try_remove(model_output_desc)
+ gscript.try_remove(model_output_csv)
+ gscript.try_remove(model_output_csvt)
gscript.try_remove(r_commands)
if reclass_files:
for reclass_file in reclass_files.itervalues():
@@ -251,8 +251,8 @@
global trainmap
global feature_vars
global training_vars
- global model_output
- global model_output_desc
+ global model_output_csv
+ global model_output_csvt
global temptable
global r_commands
global reclass_files
@@ -483,8 +483,9 @@
r_file.write("\n")
if allmap and not flags['f']:
- model_output = '.gscript_tmp_model_output_%d.csv' % os.getpid()
- write_string = "write.csv(resultsdf, '%s'," % model_output
+ model_output = gscript.tempfile()
+ model_output_csv = model_output + '.csv'
+ write_string = "write.csv(resultsdf, '%s'," % model_output_csv
write_string += " row.names=FALSE, quote=FALSE)"
r_file.write(write_string)
r_file.write("\n")
@@ -575,10 +576,10 @@
if allmap and not flags['f']:
- model_output_desc = model_output + 't'
+ model_output_csvt = model_output + '.csvt'
temptable = 'classif_tmp_table_%d' % os.getpid()
- f = open(model_output_desc, 'w')
+ f = open(model_output_csvt, 'w')
header_string = '"Integer"'
if flags['i']:
for classifier in classifiers:
@@ -595,7 +596,7 @@
gscript.message("Loading results into attribute table")
gscript.run_command('db.in.ogr',
- input_=model_output,
+ input_=model_output_csv,
output=temptable,
overwrite=True,
quiet=True)
More information about the grass-commit
mailing list