[GRASS-SVN] r57733 - grass/trunk/scripts/d.shadedmap
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 18 01:03:43 PDT 2013
Author: hamish
Date: 2013-09-18 01:03:43 -0700 (Wed, 18 Sep 2013)
New Revision: 57733
Modified:
grass/trunk/scripts/d.shadedmap/d.shadedmap.html
grass/trunk/scripts/d.shadedmap/d.shadedmap.py
Log:
add option to save result to a new raster map (merge from devbr6)
Modified: grass/trunk/scripts/d.shadedmap/d.shadedmap.html
===================================================================
--- grass/trunk/scripts/d.shadedmap/d.shadedmap.html 2013-09-18 07:33:34 UTC (rev 57732)
+++ grass/trunk/scripts/d.shadedmap/d.shadedmap.html 2013-09-18 08:03:43 UTC (rev 57733)
@@ -2,33 +2,57 @@
<em>d.shadedmap</em> will drape a color raster map over a shaded relief map.
+
<h2>NOTES</h2>
-refer to the <em>d.his</em> help page for more details; <em>d.shadedmap</em>
+Refer to the <em>d.his</em> help page for more details; <em>d.shadedmap</em>
is simply a frontend to that module.
+<p>
+If the <b>output</b> option is given the rendering will be written to a
+new raster map. The <b>output</b> map does not respect the <b>brighten</b>
+parameter. <!-- at this time. -->
-<h2>EXAMPLE</h2>
+<h2>EXAMPLES</h2>
-In this example, the aspect map in the North Carolina sample
-dataset location is used to hillshade the elevation map:
+In this example, the <tt>aspect</tt> map in the North Carolina sample
+dataset location is used to hillshade the <tt>elevation</tt> map:
<div class="code"><pre>
g.region rast=aspect -p
d.shadedmap reliefmap=aspect drapemap=elevation
</pre></div>
+In this next example, a shaded relief raster map is created in
+the Spearfish sample dataset and used to create a colorized hillshade
+raster map for later use:
+
+<div class="code"><pre>
+g.region rast=elevation.10m
+r.colors -e map=elevation.10m color=haxby
+r.shaded.relief elevation.10m
+
+d.shadedmap reliefmap=elevation.10m.shade drapemap=elevation.10m \
+ output=elevation.10m.shade.colorized
+
+r.colors -r map=elevation.10m
+</pre></div>
+
+
<h2>SEE ALSO</h2>
<em>
<a href="d.his.html">d.his</a>,
<a href="g.pnmcomp.html">g.pnmcomp</a>,
-<a href="wxGUI.nviz.html">wxGUI 3D viewer</a>,
+<a href="r.his.html">r.his</a>,
<a href="r.slope.aspect.html">r.slope.aspect</a>,
-<a href="r.shaded.relief.html">r.shaded.relief</a>
+<a href="r.shaded.relief.html">r.shaded.relief</a><br>
+<a href="wxGUI.nviz.html">wxGUI 3D viewer (NVIZ)</a>
</em>
+
<h2>AUTHORS</h2>
Unknown; updated to GRASS 5.7 by Michael Barton
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>
Modified: grass/trunk/scripts/d.shadedmap/d.shadedmap.py
===================================================================
--- grass/trunk/scripts/d.shadedmap/d.shadedmap.py 2013-09-18 07:33:34 UTC (rev 57732)
+++ grass/trunk/scripts/d.shadedmap/d.shadedmap.py 2013-09-18 08:03:43 UTC (rev 57733)
@@ -2,15 +2,15 @@
#
############################################################################
#
-# MODULE: d.shadedmap
-# AUTHOR(S): Unknown; updated to GRASS 5.7 by Michael Barton
-# Converted to Python by Glynn Clements
-# PURPOSE: Uses d.his to drape a color raster over a shaded relief map
-# COPYRIGHT: (C) 2004,2008 by the GRASS Development Team
+# MODULE: d.shadedmap
+# AUTHOR(S): Unknown; updated to GRASS 5.7 by Michael Barton
+# Converted to Python by Glynn Clements
+# PURPOSE: Uses d.his to drape a color raster over a shaded relief map
+# COPYRIGHT: (C) 2004-2013 by the GRASS Development Team
#
-# This program is free software under the GNU General Public
-# License (>=v2). Read the file COPYING that comes with GRASS
-# for details.
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
#
#############################################################################
@@ -34,7 +34,13 @@
#% options: -99-99
#% answer: 0
#%end
+#%option G_OPT_R_OUTPUT
+#% description: Create raster map from result (optional)
+#% required: no
+#%end
+
+import os
import sys
from grass.script import core as grass
@@ -42,9 +48,28 @@
drape_map = options['drapemap']
relief_map = options['reliefmap']
brighten = options['brighten']
- ret = grass.run_command("d.his", h_map = drape_map, i_map = relief_map, brighten = brighten)
+ output_map = options['output']
+
+ if output_map:
+ tmp_base = "tmp_drape.%d" % os.getpid()
+ tmp_r = tmp_base + '.r'
+ tmp_g = tmp_base + '.g'
+ tmp_b = tmp_base + '.b'
+
+ grass.run_command('r.his', h_map = drape_map, i_map = relief_map,
+ r_map = tmp_r, g_map = tmp_g, b_map = tmp_b)
+ grass.run_command('r.composite', red = tmp_r, green = tmp_g,
+ blue = tmp_b, output = output_map)
+ grass.run_command('g.remove', quiet = True,
+ rast = '%s,%s,%s' % (tmp_r, tmp_g, tmp_b))
+
+
+ ret = grass.run_command("d.his", h_map = drape_map, i_map = relief_map,
+ brighten = brighten)
+
sys.exit(ret)
+
if __name__ == "__main__":
options, flags = grass.parser()
main()
More information about the grass-commit
mailing list