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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 5 11:21:16 PST 2016


Author: pvanbosgeo
Date: 2016-01-05 11:21:16 -0800 (Tue, 05 Jan 2016)
New Revision: 67489

Modified:
   grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py
Log:
r.recode_attr addon: added option to align the current region to the input raster map (from r.recode)

Modified: grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py
===================================================================
--- grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py	2016-01-05 18:51:04 UTC (rev 67488)
+++ grass-addons/grass7/raster/r.recode.attr/r.recode.attr.py	2016-01-05 19:21:16 UTC (rev 67489)
@@ -8,7 +8,7 @@
 # PURPOSE:      Recode raster to one or more new layers using an
 #               attribute table (csv file) as input
 #
-# COPYRIGHT: (C) 2014 Paulo van Breugel
+# COPYRIGHT: (C) 2015 Paulo van Breugel
 #            http://ecodiv.org
 #            http://pvanb.wordpress.com/
 #
@@ -19,7 +19,7 @@
 ########################################################################
 #
 #%Module
-#% description: Recode raster using attribute table (csv file) as input
+#% description: Recode raster using attribute table (csv file) as input.
 #% keyword: raster
 #% keyword: recode
 #%End
@@ -50,6 +50,11 @@
 #% required: yes
 #%end
 
+#%flag:
+#% key: a
+#% description: Align the current region to the input raster map
+#%end
+
 # import libraries
 import os
 import sys
@@ -91,6 +96,7 @@
     rules = options['rules']
     outNames = outBase.split(',')
     lengthNames = len(outNames)
+    flag_a = flags['a']
 
     # Get attribute data
     myData = np.genfromtxt(rules, delimiter=',', skip_header=1)
@@ -111,11 +117,17 @@
         else:
             nmOutput = outNames[0] + '_' + nmsData[y]
 
-        grass.run_command('r.recode',
-                input = inputmap,
-                output = nmOutput,
-                rules = tmpname)
-
+        if flag_a:
+            grass.run_command('r.recode',
+                    input = inputmap,
+                    output = nmOutput,
+                    rules = tmpname,
+                    flags = "a")
+        else:
+            grass.run_command('r.recode',
+                    input = inputmap,
+                    output = nmOutput,
+                    rules = tmpname)
         os.remove(tmpname)
 
 



More information about the grass-commit mailing list