[GRASS-SVN] r61829 - grass/trunk/scripts/r.reclass.area

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 7 07:09:28 PDT 2014


Author: annakrat
Date: 2014-09-07 07:09:28 -0700 (Sun, 07 Sep 2014)
New Revision: 61829

Modified:
   grass/trunk/scripts/r.reclass.area/r.reclass.area.py
Log:
r.reclass.area: add -d flag for clumping diagonal cells - #2400

Modified: grass/trunk/scripts/r.reclass.area/r.reclass.area.py
===================================================================
--- grass/trunk/scripts/r.reclass.area/r.reclass.area.py	2014-09-07 13:54:13 UTC (rev 61828)
+++ grass/trunk/scripts/r.reclass.area/r.reclass.area.py	2014-09-07 14:09:28 UTC (rev 61829)
@@ -54,6 +54,11 @@
 #% description: Input map is clumped
 #%end
 
+#%flag
+#% key: d
+#% description: Clumps including diagonal neighbors
+#%end
+
 import sys
 import os
 import atexit
@@ -68,6 +73,7 @@
     greater = options['greater']
     outfile = options['output']
     clumped = flags['c']
+    diagonal = flags['d']
 
     s = grass.read_command("g.region", flags='p')
     kv = grass.parse_key_val(s, sep=':')
@@ -88,6 +94,9 @@
     if not grass.find_file(infile)['name']:
         grass.fatal(_("Raster map <%s> not found") % infile)
 
+    if clumped and diagonal:
+        grass.fatal(_("flags c and d are mutually exclusive"))
+
     if clumped:
         clumpfile = infile
     else:
@@ -97,10 +106,13 @@
         if not grass.overwrite():
             if grass.find_file(clumpfile)['name']:
                 grass.fatal(_("Temporary raster map <%s> exists") % clumpfile)
+        if diagonal:
+            grass.message(_("Generating a clumped raster file including diagonal neighbors..."))
+            grass.run_command('r.clump', flags='d', input=infile, output=clumpfile)
+        else:
+            grass.message(_("Generating a clumped raster file ..."))
+            grass.run_command('r.clump', input=infile, output=clumpfile)
 
-        grass.message(_("Generating a clumped raster file ..."))
-        grass.run_command('r.clump', input=infile, output=clumpfile)
-
     if lesser:
         grass.message(_("Generating a reclass map with area size less than " \
                         "or equal to %f hectares...") % limit)



More information about the grass-commit mailing list