[GRASS-SVN] r68893 - grass-addons/grass7/raster/r.mess

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 8 01:18:05 PDT 2016


Author: pvanbosgeo
Date: 2016-07-08 01:18:05 -0700 (Fri, 08 Jul 2016)
New Revision: 68893

Modified:
   grass-addons/grass7/raster/r.mess/r.mess.py
Log:
Added check for ref_rast map to be of type cell and with values limited to 1 and 0

Modified: grass-addons/grass7/raster/r.mess/r.mess.py
===================================================================
--- grass-addons/grass7/raster/r.mess/r.mess.py	2016-07-08 02:28:49 UTC (rev 68892)
+++ grass-addons/grass7/raster/r.mess/r.mess.py	2016-07-08 08:18:05 UTC (rev 68893)
@@ -205,6 +205,17 @@
     ref_rast = options['ref_rast']
     ref_vect = options['ref_vect']
 
+    # Check if ref_rast map is of type cell and values are limited to 1 and 0
+    if ref_rast:
+        reftype = gs.raster_info(ref_rast)
+        if reftype['datatype'] != "CELL":
+            gs.fatal(_("The ref_rast map must have type CELL (integer)"))
+        if reftype['min'] != 0 or reftype['max'] != 1:
+            grass.fatal(_("The ref_rast map must be a binary raster,"
+                          " i.e. it should contain only values 0 and 1"
+                          " (now the minimum is %d and maximum is %d)")
+                        % (reftype['min'], reftype['max']))
+
     # old environmental layers & variable names
     REF = options['env']
     REF = REF.split(',')
@@ -409,8 +420,7 @@
                        type="point", output=tmpf0)
         gs.run_command("v.db.addtable", quiet=True, map=tmpf0)
 
-        # TODO: mask is removed here because in the for loop below it is set and
-        # and removed at each iteration. Need a better way to do this.
+        # TODO: see if there is a more efficient way to handle the mask
         if citiam['fullname']:
             gs.run_command("r.mask", quiet=True, flags="r")
 



More information about the grass-commit mailing list