[GRASS-SVN] r51337 - in grass-addons/grass6/raster: . r.stream.preview

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 9 15:37:32 EDT 2012


Author: madi
Date: 2012-04-09 12:37:31 -0700 (Mon, 09 Apr 2012)
New Revision: 51337

Added:
   grass-addons/grass6/raster/r.stream.preview/
   grass-addons/grass6/raster/r.stream.preview/Makefile
   grass-addons/grass6/raster/r.stream.preview/description.html
   grass-addons/grass6/raster/r.stream.preview/r.stream.preview.py
Log:
renamed r.preview

Added: grass-addons/grass6/raster/r.stream.preview/Makefile
===================================================================
--- grass-addons/grass6/raster/r.stream.preview/Makefile	                        (rev 0)
+++ grass-addons/grass6/raster/r.stream.preview/Makefile	2012-04-09 19:37:31 UTC (rev 51337)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.stream.preview.py
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script

Added: grass-addons/grass6/raster/r.stream.preview/description.html
===================================================================
--- grass-addons/grass6/raster/r.stream.preview/description.html	                        (rev 0)
+++ grass-addons/grass6/raster/r.stream.preview/description.html	2012-04-09 19:37:31 UTC (rev 51337)
@@ -0,0 +1,26 @@
+<h2>DESCRIPTION</h2>
+<em>r.stream.preview</em> Creates a preview of stream extraction for a threshold value 
+and a given flow accumulation map.
+
+<h2>NOTES</h2>
+<p>In order to find a value of upslope area to be used as input to extract the 
+river network using r.stream.extract or r.watershed, it is common to proceed 
+by attempts. This tool is useful for quickly display results for various 
+attempts of threshold values.
+
+<h2>EXAMPLE</h2>
+
+<p>r.stream.preview acc=accumulation_map th=value
+
+<h2>SEE ALSO</h2>
+
+<em>
+<a href="r.stream.extract.html">r.stream.extract</a>, 
+<a href="r.watershed.html">r.watershed</a>
+</em>
+
+<h2>AUTHOR</h2>
+<p>Margherita Di Leo (dileomargherita AT gmail DOT com)
+
+
+

Added: grass-addons/grass6/raster/r.stream.preview/r.stream.preview.py
===================================================================
--- grass-addons/grass6/raster/r.stream.preview/r.stream.preview.py	                        (rev 0)
+++ grass-addons/grass6/raster/r.stream.preview/r.stream.preview.py	2012-04-09 19:37:31 UTC (rev 51337)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:      r.stream.preview.py
+# AUTHOR(S):   Margherita Di Leo
+# PURPOSE:     Create a preview for threshold value given the flow accumulation map
+# COPYRIGHT:   (C) 2012 by Margherita Di Leo 
+#              dileomargherita at gmail.com
+#
+#              This program is free software under the GNU General Public
+#              License (>=v3.0) and comes with ABSOLUTELY NO WARRANTY.
+#              See the file COPYING that comes with GRASS
+#              for details.
+#
+#############################################################################
+
+#%module
+#% description: Create a preview for a threshold value given the flow accumulation map
+#% keywords: raster
+#%end
+#%option
+#% key: acc
+#% type: string
+#% gisprompt: old,raster,raster
+#% key_desc: flow accumulation
+#% description: Name of flow accumulation raster map 
+#% required: yes
+#%end
+#%option
+#% key: th
+#% type: double
+#% key_desc: threshold
+#% description: threshold (integer)
+#% required: yes
+#%end
+
+import sys
+import os
+import grass.script as grass
+
+if not os.environ.has_key("GISBASE"):
+    grass.message( "You must be in GRASS GIS to run this program." )
+    sys.exit(1)
+    
+def main():    
+    r_acc = options['acc']
+    th = options['th']
+
+    # Creates temp rules file
+    tmp = open('rules', 'w')
+    tmp.write('*:' + th + ':0' + '\n')
+    tmp.write(th + ':*:1')
+    tmp.close()
+    
+    # recode
+    grass.run_command('r.recode', input = r_acc,
+                                  output = 'r_preview',
+                                  rules = 'rules',
+                                  overwrite = 'True')
+
+    # Delete temp rules file 
+    os.remove('rules')
+
+    # display
+    grass.run_command( 'd.mon', stop = 'x1' )
+    grass.run_command( 'd.mon', start = 'x1' )
+    grass.run_command( 'd.rast', map = 'r_preview' )
+
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    sys.exit(main())


Property changes on: grass-addons/grass6/raster/r.stream.preview/r.stream.preview.py
___________________________________________________________________
Added: svn:executable
   + *



More information about the grass-commit mailing list