[GRASS-SVN] r71637 - grass-addons/grass7/raster/r.threshold
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Nov 3 20:14:53 PDT 2017
Author: annakrat
Date: 2017-11-03 20:14:53 -0700 (Fri, 03 Nov 2017)
New Revision: 71637
Modified:
grass-addons/grass7/raster/r.threshold/r.threshold.py
Log:
r.threshold: add -g flag
Modified: grass-addons/grass7/raster/r.threshold/r.threshold.py
===================================================================
--- grass-addons/grass7/raster/r.threshold/r.threshold.py 2017-11-03 17:21:39 UTC (rev 71636)
+++ grass-addons/grass7/raster/r.threshold/r.threshold.py 2017-11-04 03:14:53 UTC (rev 71637)
@@ -32,6 +32,12 @@
#% required: yes
#%END
+#%flag
+#% key: g
+#% description: Print the threshold value in shell script style
+#%end
+
+from __future__ import print_function
import os, sys
import math
import numpy as np
@@ -57,14 +63,17 @@
index = np.where(distance==min(distance))
th = area[index]
-
+
if th < 0:
grass.warning("Flow accumulation contains negative values")
+ if flags['g']:
+ print("threshold=%d" % th)
else:
- grass.message("Suggested threshold is %d" % th )
-
- grass.message("Done!")
-
+ if flags['g']:
+ print("threshold=%d" % th)
+ else:
+ grass.message("Suggested threshold is %d" % th)
+
return 0
if __name__ == "__main__":
More information about the grass-commit
mailing list