[GRASS-SVN] r64220 - grass-addons/grass7/raster/r.niche.similarity

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 16 05:37:01 PST 2015


Author: pvanbosgeo
Date: 2015-01-16 05:37:01 -0800 (Fri, 16 Jan 2015)
New Revision: 64220

Modified:
   grass-addons/grass7/raster/r.niche.similarity/r.niche.similarity.py
Log:
Problem with changing order of output in grass.parse_command("r.covar"...); not sure what is going on so using grass.read_command instead


Modified: grass-addons/grass7/raster/r.niche.similarity/r.niche.similarity.py
===================================================================
--- grass-addons/grass7/raster/r.niche.similarity/r.niche.similarity.py	2015-01-16 13:10:27 UTC (rev 64219)
+++ grass-addons/grass7/raster/r.niche.similarity/r.niche.similarity.py	2015-01-16 13:37:01 UTC (rev 64220)
@@ -69,7 +69,7 @@
 ##----------------------------------------------------------------------------
 # Test purposes
 ##----------------------------------------------------------------------------
-#options = {"maps":"bio_1,bio_5,bio_6", "output":""}
+#options = {"maps":"bio_1,bio_2,bio_3,bio_4,bio_5,bio_6,bio_7,bio_8, bio_9", "output":""}
 #flags = {"i":True, "d":True, "c":True}
 
 ##----------------------------------------------------------------------------
@@ -149,7 +149,7 @@
 
     # Open text file for writing and write heading
     text_file = open(OPF, "w")
-    text_file.write("raster1,raster2,statistic,value" + "\n")
+    text_file.write("statistic,raster1,raster2,value" + "\n")
 
     # Write D and I values to standard output and optionally to text file
     i = 0
@@ -210,8 +210,9 @@
             #=======================================================================
 
             if flag_c:
-                corl = str(list(grass.parse_command("r.covar", quiet=True, flags="r", map=(nlay1,nlay2)))[0])
-                corl = float(corl.split(' ')[0])
+                corl = grass.read_command("r.covar", quiet=True, flags="r", map=(nlay1,nlay2))
+                corl = corl.split('N = ')[1]
+                corl = float(corl.split(' ')[1])
                 text_file.write("corr," + nvar1 + "," + nvar2 + "," + str(corl) + "\n")
                 grass.message("Correlation of " + nvar1 + " and " + nvar2 + ": " + str(round(corl, 3)))
 



More information about the grass-commit mailing list