[GRASS-SVN] r69298 - grass-addons/grass7/imagery/i.segment.stats
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 29 07:11:48 PDT 2016
Author: mlennert
Date: 2016-08-29 07:11:48 -0700 (Mon, 29 Aug 2016)
New Revision: 69298
Modified:
grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py
Log:
i.segment.stats: make absence of r.object.geometry fatal and handle global variables even in that case
Modified: grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py
===================================================================
--- grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py 2016-08-29 13:29:46 UTC (rev 69297)
+++ grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py 2016-08-29 14:11:48 UTC (rev 69298)
@@ -94,11 +94,18 @@
if insert_sql:
os.remove(insert_sql)
- os.remove(stats_temp_file)
+ if stats_temp_file:
+ os.remove(stats_temp_file)
def main():
+ global insert_sql
+ insert_sql = None
+ global temporary_vect
+ temporary_vect = None
+ global stats_temp_file
+ stats_temp_file = None
segment_map = options['map']
csvfile = options['csvfile'] if options['csvfile'] else []
@@ -109,10 +116,9 @@
if area_measures:
if not gscript.find_program('r.object.geometry', '--help'):
message = _("You need to install the addon r.object.geometry to be able")
- message += _(" to calculate area measures. Ignoring these measures for now.")
+ message += _(" to calculate area measures.\n")
message += _(" You can install the addon with 'g.extension r.object.geometry'")
- gscript.warning(message)
- r_object_geometry = False
+ gscript.fatal(message)
raster_statistics = options['raster_statistics'].split(',') if options['raster_statistics'] else []
separator = gscript.separator(options['separator'])
@@ -120,11 +126,6 @@
output_header = ['cat']
output_dict = collections.defaultdict(list)
- global insert_sql
- insert_sql = None
- global temporary_vect
- temporary_vect = None
-
raster_stat_dict = {'zone': 0, 'min': 4, 'third_quart': 16, 'max': 5, 'sum':
12, 'null_cells': 3, 'median': 15, 'label': 1, 'first_quart': 14,
'range': 6, 'mean_of_abs': 8, 'stddev': 9, 'non_null_cells': 2,
@@ -138,7 +139,6 @@
gscript.use_temp_region()
gscript.run_command('g.region', raster=segment_map)
- global stats_temp_file
stats_temp_file = gscript.tempfile()
if area_measures and r_object_geometry:
gscript.message(_("Calculating geometry statistics"))
More information about the grass-commit
mailing list