| 1 |
<!-- meta page description: Display drivers --> |
| 2 |
<!-- meta page index: display --> |
| 3 |
|
| 4 |
The current command line rendering mechanism is direct rendering into |
| 5 |
a file. The driver is selected by setting |
| 6 |
the <code>GRASS_RENDER_IMMEDIATE</code> variable or by |
| 7 |
running <em><a href="d.mon.html">d.mon</a></em> module. |
| 8 |
|
| 9 |
<p> |
| 10 |
<b>List of available display drivers:</b> |
| 11 |
<ul> |
| 12 |
<li><a href="cairodriver.html">Cairo driver</a></li> |
| 13 |
<li><a href="pngdriver.html">PNG driver</a></li> |
| 14 |
<li><a href="psdriver.html">PS driver (Postscript)</a></li> |
| 15 |
<li><a href="htmldriver.html">HTMLMAP driver</a></li> |
| 16 |
</ul> |
| 17 |
|
| 18 |
<h2>NOTES</h2> |
| 19 |
|
| 20 |
<h3>GRASS_RENDER_COMMAND</h3> |
| 21 |
|
| 22 |
If environmental variable GRASS_RENDER_COMMAND is defined, |
| 23 |
rendering is redirected by display library to the given external command |
| 24 |
defined by this variable. Currently only Python scripts are supported. |
| 25 |
|
| 26 |
<p> |
| 27 |
Lets start with simple example of Python script called <i>render.py</i>: |
| 28 |
|
| 29 |
<div class="code"><pre> |
| 30 |
#!/usr/bin/env python3 |
| 31 |
|
| 32 |
import os |
| 33 |
import sys |
| 34 |
|
| 35 |
import grass.script as gs |
| 36 |
from grass.script import task as gtask |
| 37 |
|
| 38 |
os.environ['GRASS_RENDER_IMMEDIATE'] = 'default' |
| 39 |
os.environ['GRASS_RENDER_FILE'] = 'output.png' |
| 40 |
|
| 41 |
cmd, dcmd = gtask.cmdstring_to_tuple(sys.argv[1]) |
| 42 |
|
| 43 |
gs.run_command('d.text', text="Test of GRASS_RENDER_COMMAND redirection") |
| 44 |
|
| 45 |
os.environ['GRASS_RENDER_FILE_READ'] = 'TRUE' |
| 46 |
gs.run_command(cmd, **dcmd) |
| 47 |
</pre></div> |
| 48 |
|
| 49 |
After defining GRASS_RENDER_COMMAND variable (example for Bash): |
| 50 |
|
| 51 |
<div class="code"><pre> |
| 52 |
export GRASS_RENDER_COMMAND=render.py |
| 53 |
</pre></div> |
| 54 |
|
| 55 |
Display GRASS modules like <em><a href="d.rast.html">d.rast</a></em> |
| 56 |
or <em><a href="d.vect.html">d.vect</a></em> will be executed |
| 57 |
by <i>render.py</i> program. |
| 58 |
|
| 59 |
For example the command |
| 60 |
|
| 61 |
<div class="code"><pre> |
| 62 |
d.vect roadsmajor |
| 63 |
</pre></div> |
| 64 |
|
| 65 |
produces output PNG file <i>output.png</i> which will contain rendered |
| 66 |
features from vector map <i>roadsmajor</i> and sample text <i>"Test of |
| 67 |
GRASS_RENDER_COMMAND redirection"</i>. |
| 68 |
|
| 69 |
<h2>SEE ALSO</h2> |
| 70 |
|
| 71 |
<em> |
| 72 |
<a href="d.mon.html">d.mon</a>, |
| 73 |
<a href="variables.html#list-of-selected-grass-environment-variables-for-rendering">variables</a> |
| 74 |
</em> |