[GRASS-SVN] r73247 - grass-addons/grass7/imagery/i.segment.uspo
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 4 05:46:07 PDT 2018
Author: mlennert
Date: 2018-09-04 05:46:07 -0700 (Tue, 04 Sep 2018)
New Revision: 73247
Modified:
grass-addons/grass7/imagery/i.segment.uspo/i.segment.uspo.py
Log:
i.segment.uspo: use r.info, not r.category to test for number of segments
Modified: grass-addons/grass7/imagery/i.segment.uspo/i.segment.uspo.py
===================================================================
--- grass-addons/grass7/imagery/i.segment.uspo/i.segment.uspo.py 2018-09-04 10:18:14 UTC (rev 73246)
+++ grass-addons/grass7/imagery/i.segment.uspo/i.segment.uspo.py 2018-09-04 12:46:07 UTC (rev 73247)
@@ -339,23 +339,25 @@
for minsize in iter(minsize_queue.get, 'STOP'):
map_list = rg_hierarchical_seg(parms, thresholds, minsize)
for mapname, threshold, minsize in map_list:
- variance_per_raster = []
- autocor_per_raster = []
- neighbordict = get_nb_matrix(mapname)
- for raster in parms['rasters']:
- # there seems to be some trouble in ms windows with qualified
- # map names
- raster = raster.split('@')[0]
- var = get_variance(mapname, raster)
- variance_per_raster.append(var)
- autocor = get_autocorrelation(mapname, raster,
- neighbordict, parms['indicator'])
- autocor_per_raster.append(autocor)
+ mapinfo = gscript.raster_info(mapname)
+ if mapinfo['max'] > mapinfo['min']:
+ variance_per_raster = []
+ autocor_per_raster = []
+ neighbordict = get_nb_matrix(mapname)
+ for raster in parms['rasters']:
+ # there seems to be some trouble in ms windows with qualified
+ # map names
+ raster = raster.split('@')[0]
+ var = get_variance(mapname, raster)
+ variance_per_raster.append(var)
+ autocor = get_autocorrelation(mapname, raster,
+ neighbordict, parms['indicator'])
+ autocor_per_raster.append(autocor)
- mean_lv = sum(variance_per_raster) / len(variance_per_raster)
- mean_autocor = sum(autocor_per_raster) / len(autocor_per_raster)
- result_queue.put([mapname, mean_lv, mean_autocor,
- threshold, minsize])
+ mean_lv = sum(variance_per_raster) / len(variance_per_raster)
+ mean_autocor = sum(autocor_per_raster) / len(autocor_per_raster)
+ result_queue.put([mapname, mean_lv, mean_autocor,
+ threshold, minsize])
except:
result_queue.put(["%s: %s_%d failed" % (current_process().name,
@@ -370,9 +372,8 @@
try:
for threshold, minsize in iter(parameter_queue.get, 'STOP'):
mapname = rg_non_hierarchical_seg(parms, threshold, minsize)
- numsegments = len(gscript.read_command('r.category',
- map_=mapname).splitlines())
- if numsegments > 1:
+ mapinfo = gscript.raster_info(mapname)
+ if mapinfo['max'] > mapinfo['min']:
variance_per_raster = []
autocor_per_raster = []
neighbordict = get_nb_matrix(mapname)
More information about the grass-commit
mailing list