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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 8 16:40:15 EDT 2012


Author: madi
Date: 2012-04-08 13:40:15 -0700 (Sun, 08 Apr 2012)
New Revision: 51317

Added:
   grass-addons/grass6/raster/r.preview/
   grass-addons/grass6/raster/r.preview/Makefile
   grass-addons/grass6/raster/r.preview/description.html
   grass-addons/grass6/raster/r.preview/r.preview.py
Log:
new module for creating a quick preview of stream extraction varying the threshold

Added: grass-addons/grass6/raster/r.preview/Makefile
===================================================================
--- grass-addons/grass6/raster/r.preview/Makefile	                        (rev 0)
+++ grass-addons/grass6/raster/r.preview/Makefile	2012-04-08 20:40:15 UTC (rev 51317)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.preview.py
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script

Added: grass-addons/grass6/raster/r.preview/description.html
===================================================================
--- grass-addons/grass6/raster/r.preview/description.html	                        (rev 0)
+++ grass-addons/grass6/raster/r.preview/description.html	2012-04-08 20:40:15 UTC (rev 51317)
@@ -0,0 +1,21 @@
+<h2>DESCRIPTION</h2>
+<em>r.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.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.preview/r.preview.py
===================================================================
--- grass-addons/grass6/raster/r.preview/r.preview.py	                        (rev 0)
+++ grass-addons/grass6/raster/r.preview/r.preview.py	2012-04-08 20:40:15 UTC (rev 51317)
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:      r.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']
+    
+    print r_acc
+    print 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.preview/r.preview.py
___________________________________________________________________
Added: svn:executable
   + *



More information about the grass-commit mailing list