[GRASS-SVN] r68680 - grass-addons/grass7/imagery/i.segment.stats

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 14 03:23:29 PDT 2016


Author: mlennert
Date: 2016-06-14 03:23:28 -0700 (Tue, 14 Jun 2016)
New Revision: 68680

Modified:
   grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.html
   grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py
Log:
i.segment.stats: leave it up to the user to run r.clump if necessary


Modified: grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.html
===================================================================
--- grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.html	2016-06-13 19:43:53 UTC (rev 68679)
+++ grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.html	2016-06-14 10:23:28 UTC (rev 68680)
@@ -1,30 +1,42 @@
 <h2>DESCRIPTION</h2>
 
+<p>
 <em>i.segment.stats</em> calculates statistics for areas in a raster
 map. Areas are defined by adjacent pixels with the same value. Such
 areas can be the output of <a href="i.segment.html">i.segment</a> or
 <a href="r.clump.html">r.clump</a>.
 
+<p>
 Available statistics are those related to the shape and size of the areas
 (see the <a href="v.to.db.html">v.to.db</a> man page for more information
 on the statistics) and aggregated statistics of pixel values of other
 raster maps (see <a href="v.univar.html">v.univar</a> for details).
 
+<p>
 The user can chose between output in the form of a vector map of the areas
 with the statistics in the attribute table and/or in the form of a CSV
 text file.
 
 <h2>NOTES</h2>
 
+<p>
 The module respects the current region settings. The <em>-r</em> flag allows
 to force the module to adjust the region to the input raster map before
 calculating the statistics.
 
+<p>
 This module is a simple front-end to <a href="v.univar.html">v.univar</a>
 and <a href="v.to.db.html">v.to.db</a>. If other statistics are desired,
 these should probably be implemented in those (or other) modules which
 can then be called from this module.
 
+<p>
+Problems can arise in the calculation of some form statistics for certain
+segment forms. If errors arise, the user might want to try to run 
+<a href="r.clump.html">r.clump</a> on the input raster file before running
+<em>i.segment.stats</em>.
+
+
 <h2>EXAMPLE</h2>
 
 <div class="code"><pre>

Modified: grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py
===================================================================
--- grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py	2016-06-13 19:43:53 UTC (rev 68679)
+++ grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py	2016-06-14 10:23:28 UTC (rev 68680)
@@ -87,9 +87,6 @@
     if grass.find_file(temporary_vect, element='vector')['name']:
             grass.run_command('g.remove', flags='f', type_='vector',
                     name=temporary_vect, quiet=True)
-    if grass.find_file(temporary_clumped_rast, element='cell')['name']:
-            grass.run_command('g.remove', flags='f', type_='raster',
-                    name=temporary_clumped_rast, quiet=True)
     if insert_sql:
         os.remove(insert_sql)
 
@@ -111,8 +108,6 @@
     insert_sql = None
 
     global temporary_vect
-    global temporary_clumped_rast
-    temporary_clumped_rast = 'segmstat_tmp_clumpedrast_%d' % os.getpid()
     temporary_vect = 'segmstat_tmp_vect_%d' % os.getpid()
 
     raster_stat_dict = {'zone': 0, 'min': 4, 'third_quart': 16, 'max': 5, 'sum':
@@ -125,12 +120,8 @@
         grass.use_temp_region()
         grass.run_command('g.region', raster=segment_map)
 
-    grass.run_command('r.clump',
-                      input_=segment_map,
-                      output=temporary_clumped_rast,
-                      quiet=True)
     grass.run_command('r.to.vect',
-                      input_=temporary_clumped_rast,
+                      input_=segment_map,
                       output=temporary_vect,
                       type_='area',
                       flags='vt')
@@ -153,7 +144,7 @@
         stat_indices = [raster_stat_dict[x] for x in raster_statistics]
         res=grass.read_command('r.univar',
                                map_=raster,
-                               zones=temporary_clumped_rast,
+                               zones=segment_map,
                                flags='et').splitlines()[1:]
         for element in res:
             values = element.split('|')



More information about the grass-commit mailing list