File: displaydrivers.html

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (74 lines) | stat: -rw-r--r-- 2,100 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!-- meta page description: Display drivers -->
<!-- meta page index: display -->

The current command line rendering mechanism is direct rendering into
a file. The driver is selected by setting
the <code>GRASS_RENDER_IMMEDIATE</code> variable or by
running <em><a href="d.mon.html">d.mon</a></em> module.

<p>
<b>List of available display drivers:</b>
<ul>
  <li><a href="cairodriver.html">Cairo driver</a></li>
  <li><a href="pngdriver.html">PNG driver</a></li>
  <li><a href="psdriver.html">PS driver (Postscript)</a></li>
  <li><a href="htmldriver.html">HTMLMAP driver</a></li>
</ul>

<h2>NOTES</h2>

<h3>GRASS_RENDER_COMMAND</h3>

If environmental variable GRASS_RENDER_COMMAND is defined,
rendering is redirected by display library to the given external command
defined by this variable. Currently only Python scrips are supported.

<p>
Lets start with simple example of Python script called <i>render.py</i>:

<div class="code"><pre>
#!/usr/bin/env python3

import os
import sys

import grass.script as gs
from grass.script import task as gtask

os.environ['GRASS_RENDER_IMMEDIATE'] = 'default'
os.environ['GRASS_RENDER_FILE'] = 'output.png'

cmd, dcmd = gtask.cmdstring_to_tuple(sys.argv[1])

gs.run_command('d.text', text="Test of GRASS_RENDER_COMMAND redirection")

os.environ['GRASS_RENDER_FILE_READ'] = 'TRUE'
gs.run_command(cmd, **dcmd)
</pre></div>

After defining GRASS_RENDER_COMMAND variable (example for Bash):

<div class="code"><pre>
export GRASS_RENDER_COMMAND=render.py
</pre></div>

Display GRASS modules like <em><a href="d.rast.html">d.rast</a></em>
or <em><a href="d.vect.html">d.vect</a></em> will be executed
by <i>render.py</i> program.

For example the command

<div class="code"><pre>
d.vect roadsmajor
</pre></div>

produces output PNG file <i>output.png</i> which will contain rendered
features from vector map <i>roadsmajor</i> and sample text <i>&quot;Test of
GRASS_RENDER_COMMAND redirection&quot;</i>.

<h2>SEE ALSO</h2>

<em>
<a href="d.mon.html">d.mon</a>,
<a href="variables.html#list-of-selected-grass-environment-variables-for-rendering">variables</a>
</em>