浏览代码

d.to.rast: fix missing parts in https://trac.osgeo.org/grass/changeset/62394

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@62423 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 10 年之前
父节点
当前提交
cb78edac8e
共有 4 个文件被更改,包括 105 次插入0 次删除
  1. 7 0
      scripts/d.to.rast/Makefile
  2. 51 0
      scripts/d.to.rast/d.to.rast.html
  3. 47 0
      scripts/d.to.rast/d.to.rast.py
  4. 二进制
      scripts/d.to.rast/d_to_rast_3D_example.jpg

+ 7 - 0
scripts/d.to.rast/Makefile

@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = d.to.rast
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script

+ 51 - 0
scripts/d.to.rast/d.to.rast.html

@@ -0,0 +1,51 @@
+<h2>DESCRIPTION</h2>
+
+<em>d.to.rast</em> saves the content of the currently selected
+monitor into a raster map. The active monitor can be selected
+with <em>d.mon</em>. <em>d.to.rast</em> can be run from GUI
+command console, too. This module is not sensitive to computational region settings.
+
+<h2>EXAMPLE</h2>
+We combine different raster and vector map layers to create a composite layer
+which can be draped over elevation in 3D view.
+First, we add a couple of maps to layer manager:
+
+<div class="code"><pre>
+g.region rast=elevation
+d.rast map=elevation
+d.rast map=lakes
+d.vect map=roadsmajor width=4
+d.vect map=roadsmajor width=2 color=yellow
+
+# create a raster map from the display
+d.to.rast output=composite
+</pre></div>
+
+<p>
+Then uncheck all layers except for elevation and switch to 3D view.
+In Data tab, set color map to the newly created composite map.
+
+<p>
+<center>
+<img src="d_to_rast_3D_example.jpg">
+<p>
+Figure: Raster map created by <em>d.to.rast</em> draped over digital elevation model.
+</center>
+
+
+
+<h2>SEE ALSO</h2>
+ 
+<em>
+  <a href="d.out.file.html">d.out.file</a>,
+  <a href="d.erase.html">d.erase</a>,
+  <a href="d.rast.html">d.rast</a>,
+  <a href="d.vect.html">d.vect</a>,
+  <a href="d.mon.html">d.mon</a>
+</em>
+
+<h2>AUTHOR</h2>
+
+Anna Petrasova, <a href="http://gis.ncsu.edu/osgeorel/">NCSU OSGeoREL</a>
+
+<p><i>Last changed: $Date$</i>

+ 47 - 0
scripts/d.to.rast/d.to.rast.py

@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: d.to.rast
+# AUTHOR(S): Anna Petrasova <kratochanna gmail.com>
+# PURPOSE:	Script for exporting content of monitor to raster map
+# COPYRIGHT: (C) 2014 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.
+#
+#############################################################################
+
+#%module
+#% description: Saves the contents of the active display monitor to a raster map.
+#% keywords: display
+#% keywords: export
+#% keywords: raster
+#%end
+#%option G_OPT_R_OUTPUT
+#%end
+
+
+from grass.script import core as gcore
+
+
+def main():
+    options, flags = gcore.parser()
+    print options, flags
+    gisenv = gcore.gisenv()
+    if 'MONITOR' in gisenv:
+        cmd_file = gisenv['MONITOR_{monitor}_CMDFILE'.format(monitor=gisenv['MONITOR'].upper())]
+        d_cmd = 'd.to.rast'
+        for param, val in options.iteritems():
+            if val:
+                d_cmd += " {param}={val}".format(param=param, val=val)
+        if gcore.overwrite():
+            d_cmd += ' --overwrite'
+        with open(cmd_file, "a") as file_:
+            file_.write(d_cmd)
+    else:
+        gcore.fatal(_("No graphics device selected. Use d.mon to select graphics device."))
+
+
+if __name__ == "__main__":
+    main()

二进制
scripts/d.to.rast/d_to_rast_3D_example.jpg