[GRASS-SVN] r65080 - grass-addons/grass7/raster/r.recode.attr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 16 05:26:58 PDT 2015


Author: pvanbosgeo
Date: 2015-04-16 05:26:58 -0700 (Thu, 16 Apr 2015)
New Revision: 65080

Modified:
   grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py
Log:
correction

Modified: grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py
===================================================================
--- grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py	2015-04-16 12:26:01 UTC (rev 65079)
+++ grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py	2015-04-16 12:26:58 UTC (rev 65080)
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 ########################################################################
-# 
+#
 # MODULE:       r.recode_attribute
 # AUTHOR(S):    Paulo van Breugel <p.vanbreugel AT gmail.com>
 # PURPOSE:      Recode raster to one or more new layers using an
@@ -11,18 +11,18 @@
 # COPYRIGHT: (C) 2014 Paulo van Breugel
 #            http://ecodiv.org
 #            http://pvanb.wordpress.com/
-# 
-#            This program is free software under the GNU General Public 
-#            License (>=v2). Read the file COPYING that comes with GRASS 
-#            for details. 
-# 
+#
+#            This program is free software under the GNU General Public
+#            License (>=v2). Read the file COPYING that comes with GRASS
+#            for details.
+#
 ########################################################################
 #
-#%Module 
+#%Module
 #% description: Recode raster using attribute table (csv file) as input
 #% keyword: raster
 #% keyword: recode
-#%End 
+#%End
 
 #%option
 #% key: input
@@ -44,7 +44,7 @@
 #% multiple: no
 #%end
 
-#%option G_OPT_F_INPUT
+#%option G_OPT_F_OUTPUT
 #% key: rules
 #% label: Full path to rules file
 #% required: yes
@@ -61,8 +61,8 @@
 import grass.script as grass
 
 def cleanup():
-	grass.run_command('g.remove', 
-      type = 'raster', 
+	grass.run_command('g.remove',
+      type = 'raster',
       pattern = 'tmp_map',
       flags='f',
       quiet = True)
@@ -79,46 +79,46 @@
 
 # main function
 def main():
-    
+
     # check if GISBASE is set
     if "GISBASE" not in os.environ:
     # return an error advice
        grass.fatal(_("You must be in GRASS GIS to run this program"))
-       
-    # input raster map and parameters   
+
+    # input raster map and parameters
     inputmap = options['input']
     outBase = options['output']
     rules = options['rules']
     outNames = outBase.split(',')
     lengthNames = len(outNames)
-    
+
     # Get attribute data
     myData = np.genfromtxt(rules, delimiter=',', skip_header=1)
     nmsData = np.genfromtxt(rules, delimiter=',', names=True)
     dimData = myData.shape
     nmsData = nmsData.dtype.names
-          
+
     # Create recode maps
     numVar = xrange(dimData[1]-1)
     for x in numVar:
         y = x + 1
         myRecode = np.column_stack((myData[:,0], myData[:,0], myData[:,y]))
         tmpname = CreateFileName()
-        np.savetxt(tmpname, myRecode, delimiter=":") 
-        
+        np.savetxt(tmpname, myRecode, delimiter=":")
+
         if len(numVar) == lengthNames:
             nmOutput = outNames[x]
         else:
             nmOutput = outNames[0] + '_' + nmsData[y]
-            
+
         grass.run_command('r.recode',
-                input = inputmap, 
+                input = inputmap,
                 output = nmOutput,
                 rules = '.numpy_grass_recode')
-        
-        os.remove('.numpy_grass_recode') 
 
+        os.remove('.numpy_grass_recode')
 
+
 if __name__ == "__main__":
     options, flags = grass.parser()
     sys.exit(main())



More information about the grass-commit mailing list