[GRASS-SVN] r72631 - grass-addons/grass7/raster/r.neighborhoodmatrix

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 18 00:19:05 PDT 2018


Author: mlennert
Date: 2018-04-18 00:19:05 -0700 (Wed, 18 Apr 2018)
New Revision: 72631

Modified:
   grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.html
   grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.py
Log:
r.neighborhoodmatrix: Fail if only one single category in map and allow translation of error messages


Modified: grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.html
===================================================================
--- grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.html	2018-04-18 07:10:58 UTC (rev 72630)
+++ grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.html	2018-04-18 07:19:05 UTC (rev 72631)
@@ -2,7 +2,8 @@
 
 <p>
 <em>r.neighborhoodmatrix</em> identifies all adjacency relations between
-objects (aka segments or clumps) in a raster map and exports these as a 2xn matrix 
+objects (aka segments or clumps identified by identical integer cell values of
+adjacent pixels) in a raster map and exports these as a 2xn matrix 
 where n is the number of neighborhood relations with each relation listed 
 in both directions (i.e. if a is neighbor of b, the list will contain 
 a,b and b,a). If a path to an output file is specified, the matrix will be

Modified: grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.py
===================================================================
--- grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.py	2018-04-18 07:10:58 UTC (rev 72630)
+++ grass-addons/grass7/raster/r.neighborhoodmatrix/r.neighborhoodmatrix.py	2018-04-18 07:19:05 UTC (rev 72631)
@@ -109,8 +109,13 @@
     #Check that input map is CELL
     datatype = gscript.parse_command('r.info', flags='g', map=rinput)['datatype']
     if datatype != 'CELL':
-        gscript.fatal("Input map has to be of CELL (integer) type")
+        gscript.fatal(_("Input map has to be of CELL (integer) type"))
 
+    numneighbors = len(gscript.read_command('r.category',
+                                            map_=rinput).splitlines())
+    if numneighbors < 2:
+        gscript.fatal(_("Need at least two different category values to determine neighbors"))
+
     global separator
     separator = gscript.separator(options['separator'])
     processes = int(options['processes'])



More information about the grass-commit mailing list