variables.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <!-- meta page description: GRASS variables and environment variables -->
  2. There are two types of variables:
  3. <ul>
  4. <li><a href="#enviro">shell environment</a> variables,</li>
  5. <li><a href="#gisenv">GRASS gisenv</a> variables.</li>
  6. </ul>
  7. There are a number of <i>shell</i> environment variable groups:
  8. <ul>
  9. <li><a href="#rendering">variables for rendering</a></li>
  10. <li><a href="#internal">variables for internal use</a></li>
  11. </ul>
  12. <i>Note:</i> Any setting which needs to be modifiable by a GRASS module
  13. (e.g. MONITOR by <em><a href="d.mon.html">d.mon</a></em>) has to be a GRASS
  14. gisenv variable.
  15. <h2>Setting shell environment variables</h2>
  16. Setting shell environment variables depends on the shell being used:
  17. <br><br>
  18. Bash:
  19. <div class="code"><pre>
  20. export VARIABLE=value
  21. </pre></div>
  22. Csh:
  23. <div class="code"><pre>
  24. setenv VARIABLE value
  25. </pre></div>
  26. Cmd.exe (Windows):
  27. <div class="code"><pre>
  28. set VARIABLE=value
  29. </pre></div>
  30. To set up shell environment variables permanently:
  31. <ul>
  32. <li>
  33. To get personal BASH shell definitions (aliases, color listing option, ...)
  34. into GRASS, store them in:<br>
  35. <tt>$HOME/.grass.bashrc</tt></li>
  36. <li>
  37. To get personal CSH shell definitions (aliases, color listing option, ...)
  38. into GRASS, store them in:<br>
  39. <tt>$HOME/.grass.cshrc</tt></li>
  40. </ul>
  41. <h2>Setting GRASS gisenv variables</h2>
  42. Use <em><a href="g.gisenv.html">g.gisenv</a></em> within GRASS. This permanently
  43. predefines GRASS variables in the <tt>.grass7/rc</tt> file.
  44. <br><br>
  45. Usage:
  46. <div class="code"><pre>
  47. g.gisenv set="VARIABLE=VALUE"
  48. </pre></div>
  49. It looks unusual with two equals signs, but <em>g.gisenv</em> serves dual duty for
  50. getting and setting GRASS variables.
  51. <p>If the user just specifies a variable name, it defaults to <b>get</b> mode.
  52. For example:
  53. <div class="code"><pre>
  54. g.gisenv MAPSET
  55. PERMANENT
  56. </pre></div>
  57. <a name="enviro"></a>
  58. <h2>List of selected (GRASS related) shell environment variables</h2>
  59. <blockquote>
  60. [ To be set from the terminal shell or startup scripts ]
  61. </blockquote>
  62. <dl>
  63. <dt>GISBASE</dt>
  64. <dd>directory where GRASS lives. This is set automatically by the
  65. startup script.</dd>
  66. <dt>GISRC</dt>
  67. <dd>name of <tt>.grass7/rc</tt> file. Defines the system wide value
  68. while in a GRASS session.</dd>
  69. <dt>GRASS_ADDON_PATH</dt>
  70. <dd>[grass startup script, g.extension]<br>
  71. specifies additional path(s) containing local and/or custom GRASS
  72. modules extra to the standard distribution.</dd>
  73. <dt>GRASS_ADDON_BASE</dt>
  74. <dd>[grass startup script]<br> allows to specify additional GISBASE
  75. for local GRASS modules (normally installed as GRASS Addons
  76. by <tt>g.extension</tt> module) extra to standard
  77. distribution. The default on GNU/Linux
  78. is <tt>$HOME/.grass7/addons</tt>, on MS
  79. Windows <tt>$APPDATA\GRASS7\addons</tt>.</dd>
  80. <dt>GRASS_ADDON_ETC</dt>
  81. <dd>[libgis, g.findetc]<br>
  82. specify paths where support files (etc/) may be found external to
  83. standard distribution.</dd>
  84. <dt>GRASS_BATCH_JOB</dt>
  85. <dd>defines the name (path) of a shell script to be processed as
  86. batch job.</dd>
  87. <dt>GIS_ERROR_LOG</dt>
  88. <dd>If set, GIS_ERROR_LOG should be the absolute path to the log
  89. file (a relative path will be interpreted relative to the process'
  90. cwd, not the cwd at the point the user set the variable). If not
  91. set, <tt>$HOME/GIS_ERROR_LOG</tt> is used instead. The file will
  92. only be used if it already exists.</dd>
  93. <dt>GRASS_ERROR_MAIL</dt>
  94. <dd>set to any value to send user mail on an error or warning that
  95. happens while stderr is being redirected.</dd>
  96. <dt>GRASS_FONT</dt>
  97. <dd>[display drivers]<br>
  98. specifies the font as either the name of a font from
  99. <tt>$GISBASE/etc/fontcap</tt> (or alternative fontcap file
  100. specified by GRASS_FONT_CAP), or alternatively the full path to a
  101. FreeType font file.</dd>
  102. <dt>GRASS_ENCODING</dt>
  103. <dd>[display drivers]<br>
  104. the encoding to be assumed for text which is drawn using a
  105. freetype font; may be any encoding know to <em>iconv</em>.</dd>
  106. <dt>GRASS_FONT_CAP</dt>
  107. <dd>[g.mkfontcap, d.font, display drivers]<br>
  108. specifies an alternative location (to <tt>$GISBASE/etc/fontcap</tt>) for
  109. the font configuration file.</dd>
  110. <dt>GRASS_GNUPLOT</dt>
  111. <dd>[<!-- m.svfit, s.probplt, s.sv -->i.spectral]<br>
  112. program to use for plotting <em>gnuplot</em> data.</dd>
  113. <dt>GRASS_GUI</dt>
  114. <dd>either <tt>text</tt> or <tt>gui</tt> to define non-/graphical startup.
  115. <br><br> Can also specify the name of the GUI to use,
  116. e.g. <tt>wxpython</tt>
  117. (<em><a href="wxGUI.html">wxGUI</a></em>). Also exists as a GRASS
  118. gisenv variable (see below). If this shell variable exists at
  119. GRASS startup, it will determine the GUI used. If it is not
  120. defined startup will default to the last GUI used.</dd>
  121. <dt>GRASS_HTML_BROWSER</dt>
  122. <dd>[init.sh, wxgui]<br> defines name of HTML browser. For most
  123. platforms this should be an executable in your PATH, or the full
  124. path to an executable.<br> Mac OS X runs applications differently
  125. from the CLI. Therefore, GRASS_HTML_BROWSER should be the
  126. application's signature, which is a domain-like name, just
  127. reversed, i.e. com.apple.Safari. To find an application's
  128. signature, type the following in a Terminal (fill in the path to
  129. the application you are interested in, for example:
  130. /Applications/Safari.app):<br> &nbsp; &nbsp; <code>grep -A 1
  131. &quot;CFBundleIdentifier&quot;</code> <i>/path/to/application.app</i><code>/Contents/Info.plist</code><br>
  132. &nbsp; The signature is the &lt;string&gt; following the
  133. &lt;key&gt;, without the bracketing &lt;string&gt; tags.</dd>
  134. <dt>GRASS_INT_ZLIB</dt>
  135. <dd>[libgis]<br> if the environment variable GRASS_INT_ZLIB exists,
  136. new compressed <i>integer</i> (CELL type) raster maps will be compressed
  137. using zlib instead of RLE compression. Such rasters will have a <tt>compressed</tt>
  138. value of 2 in the cellhd file.
  139. <br><br>
  140. Obviously, decompression is controlled by the
  141. raster's <tt>compressed</tt> value, not the environment variable.</dd>
  142. <dt>GRASS_MESSAGE_FORMAT</dt>
  143. <dd>[various modules, wxGUI]<br>
  144. it may be set to either
  145. <ul>
  146. <li><tt>standard</tt> - sets percentage output and message
  147. formatting style to standard formatting,</li>
  148. <li><tt>gui</tt> - sets percentage output and message formatting
  149. style to GUI formatting,</li>
  150. <li><tt>silent</tt> - disables percentage output and error
  151. messages,</li>
  152. <li><tt>plain</tt> - sets percentage output and message
  153. formatting style to ASCII output without rewinding control
  154. characters.</li>
  155. </ul></dd>
  156. <dt>GRASS_MOUSE_BUTTON</dt>
  157. <dd>[various modules]<br> swaps mouse buttons for two-button or
  158. left-handed mice. Its value has three digits 1, 2, and 3, which
  159. represent default left, middle, and right buttons
  160. respectively. Setting to <tt>132</tt> will swap middle and right
  161. buttons. Note that this variable should be set before a display
  162. driver is initialized (e.g.,
  163. <tt>d.mon x0</tt>).</dd>
  164. <dt>GRASS_PAGER</dt>
  165. <dd>[various modules]<br>
  166. it may be set to either <tt>less</tt>, <tt>more</tt>, or <tt>cat</tt>.</dd>
  167. <dt>GRASS_PERL</dt>
  168. <dd>[used during install process for generating man pages]<br>
  169. set Perl with path.</dd>
  170. <dt>GRASS_RND_SEED</dt>
  171. <dd>set random seed
  172. for <em><a href="r.mapcalc.html">r.mapcalc</a></em> rand()
  173. function.</dd>
  174. <dt>GRASS_SKIP_MAPSET_OWNER_CHECK</dt>
  175. <dd>By default it is not possible to work with MAPSETs that are
  176. not owned by current user. Setting this variable to any non-empty value
  177. allows the check to be skipped.</dd>
  178. <dt>GRASS_SH</dt>
  179. <dd>[shell scripts on Windows]<br>
  180. path to bourne shell interpreter used to run shell scripts.</dd>
  181. <dt>GRASS_SIGSEGV_ON_ERROR</dt>
  182. <dd>Raise SIGSEGV if an error occures]<br>
  183. This variable can be set for debugging purpose. The call
  184. of G_fatal_error() will end in a segmentation violation. GDB can be used
  185. to trace the source of the error.</dd>
  186. <dt>GRASS_PYTHON</dt>
  187. <dd>[wxGUI, Python Ctypes]<br>
  188. set to override Python executable.<br>
  189. On Mac OS X this should be the <tt>pythonw</tt> executable for the
  190. wxGUI to work.</dd>
  191. <dt>GRASS_VECTOR_LOWMEM</dt>
  192. <dd>[vectorlib]<br>
  193. If the environment variable GRASS_VECTOR_LOWMEM exists, memory
  194. consumption will be reduced when building vector topology
  195. support structures. Recommended for creating large vectors.</dd>
  196. <dt>GRASS_VECTOR_OGR</dt>
  197. <dd>[vectorlib, v.external.out]<br> If the environment variable
  198. GRASS_VECTOR_OGR exists and vector output format defined
  199. by <em><a href="v.external.out.html">v.external.out</a></em> is
  200. PostgreSQL, vector data is written by OGR data provider even
  201. the native PostGIS data provider is available.</dd>
  202. <dt>GRASS_VECTOR_EXTERNAL_IMMEDIATE</dt>
  203. <dd>[vectorlib, v.external.out]<br> If the environment variable
  204. GRASS_VECTOR_EXTERNAL_IMMEDIATE exists and vector output format
  205. defined
  206. by <em><a href="v.external.out.html">v.external.out</a></em> is
  207. non-native, vector features are written to output external
  208. datasource immediately. By default, the vector library writes
  209. output data to a temporary vector map in native format and when
  210. closing the map, the features are transfered to output external
  211. datasource. Note: if output vector format is topological PostGIS
  212. format, then the vector library writes features immediately to output
  213. database (in this case GRASS_VECTOR_EXTERNAL_IMMEDIATE is ignored).</dd>
  214. <dt>GRASS_VECTOR_EXTERNAL_IGNORE</dt>
  215. <dd>[vectorlib]<br> If the environment variable
  216. GRASS_VECTOR_EXTERNAL_IGNORE exists, output vector format defined
  217. by <em><a href="v.external.out.html">v.external.out</a></em> is
  218. ignored. The format is always native.</dd>
  219. <dt>GRASS_VECTOR_TEMPORARY</dt>
  220. <dd>[vectorlib]<br> If the environment variable
  221. GRASS_VECTOR_TEMPORARY exists, vector library will operate with
  222. temporary vector maps. New vector maps will be created
  223. in <tt>$MAPSET/.tmp/$HOSTNAME/vector</tt>, existing vector maps
  224. will be read also from this directory. Note that temporary vector
  225. maps are not visible to the user
  226. via <em><a href="g.list.html">g.list</a></em>. They are used
  227. internally by the GRASS modules and deleted automatically when the
  228. map is closed or GRASS session quited. Note that this variable is
  229. dedicated for internal use only.
  230. </dd>
  231. <dt>GRASS_WXBUNDLED</dt>
  232. <dd>[wxGUI]<br>
  233. set to tell wxGUI that a bundled wxPython will be used.<br>
  234. When set, the wxGUI will not check the wxPython version, as this
  235. function is incompatible with a bundled wxPython. It is up to the
  236. packager to make sure that a compatible wxPython version is bundled.</dd>
  237. <dt>GRASS_XTERM</dt>
  238. <dd>[lib/init/grass-xterm-wrapper, lib/init/grass-xterm-mac]<br>
  239. set to any value (e.g. rxvt, aterm, gnome-terminal, konsole) to
  240. substitute 'x-terminal-emulator' or 'xterm'. The Mac OS X app
  241. startup defaults to an internal '$GISBASE/etc/grass-xterm-mac',
  242. which emulates the necessary xterm functionality in
  243. Terminal.app.</dd>
  244. <dt>GRASS_UI_TERM</dt>
  245. <dd>set to any value to use the terminal based parser.</dd>
  246. <dt>GRASS_VERSION</dt>
  247. <dd>reports the current version number (used by R-stats interface etc);
  248. should not be changed by user.</dd>
  249. <dt>GRASS_NO_GLX_PBUFFERS</dt>
  250. <dd>[nviz]<br>
  251. set to any value to disable the use of GLX Pbuffers.</dd>
  252. <dt>GRASS_NO_GLX_PIXMAPS</dt>
  253. <dd>[nviz]<br>
  254. Set to any value to disable the use of GLX Pixmaps.</dd>
  255. <dt>OMP_NUM_THREADS</dt>
  256. <dd>[OpenMP]<br>
  257. If OpenMP support is enabled this limits the number of threads.
  258. The default is set to the number of CPUs on the system.
  259. Setting to '1' effectively disables parallel processing.</dd>
  260. </dl>
  261. <a name="rendering"></a>
  262. <h3>List of selected GRASS environment variables for rendering</h3>
  263. <blockquote>
  264. [ In addition to those which are understood by specific <em>GRASS display
  265. drivers</em>, the following variables affect rendering. ]
  266. </blockquote>
  267. <dl>
  268. <dt>GRASS_RENDER_IMMEDIATE</dt>
  269. <dd>tells the display library which driver to use; possible
  270. values: <em><a href="cairodriver.html">cairo</a></em>, <em><a href="pngdriver.html">png</a></em>, <em><a href="psdriver.html">ps</a></em>
  271. or <em><a href="htmldriver.html">html</a></em></dd>
  272. <dt>GRASS_WIDTH</dt>
  273. <dd>defines the width of output image (default is 640).</dd>
  274. <dt>GRASS_HEIGHT</dt>
  275. <dd>defines the height of output image (default is 480).</dd>
  276. <dt>GRASS_FRAME</dt>
  277. <dd>contains 4 coordinates, <em>top,bottom,left,right</em> (pixel values), defining the initial frame.</dd>
  278. <dt>GRASS_LINE_WIDTH</dt>
  279. <dd>defines default line width.</dd>
  280. <dt>GRASS_TEXT_SIZE</dt>
  281. <dd>defines default text size.</dd>
  282. </dl>
  283. For specific driver-related variables see:
  284. <ul>
  285. <li><em><a href="cairodriver.html">Cairo driver</a></em></li>
  286. <li><em><a href="pngdriver.html">PNG driver</a></em></li>
  287. <li><em><a href="psdriver.html">PS (Postscript) driver</a></em></li>
  288. <li><em><a href="htmldriver.html">HTML driver</a></em></li>
  289. </ul>
  290. <a name="internal"></a>
  291. <h3>List of selected internal GRASS environment variables</h3>
  292. <blockquote>
  293. [ These variables are intended <b>for internal use only</b> by the GRASS
  294. software to facilitate communication between the GIS engine, GRASS scripts,
  295. and the GUI.
  296. The user should not set these in a GRASS session. They are meant to be set
  297. locally for specific commands. ]
  298. </blockquote>
  299. <dl>
  300. <dt>GRASS_OVERWRITE</dt>
  301. <dd>[all modules]<br>
  302. toggles map overwrite.
  303. <ul>
  304. <li>0 - maps are protected (default),</li>
  305. <li>1 - maps with identical names will be overwritten.</li>
  306. </ul>
  307. This variable is automatically created
  308. by <em><a href="g.parser.html">g.parser</a></em> so that the
  309. <tt>--overwrite</tt> option will
  310. be inherited by dependent modules as the script runs. Setting either the
  311. GRASS_OVERWRITE environment variable or the OVERWRITE gisenv variable detailed
  312. below will cause maps with identical names to be overwritten.</dd>
  313. <dt>GRASS_VERBOSE</dt>
  314. <dd>[all modules]<br>
  315. toggles verbosity level
  316. <ul>
  317. <li>-1 - complete silence (also errors and warnings are discarded)</li>
  318. <li>0 - only errors and warnings are printed</li>
  319. <li>1 - progress and important messages are printed (percent complete)</li>
  320. <li>2 - all module messages are printed</li>
  321. <li>3 - additional verbose messages are printed</li>
  322. </ul>
  323. This variable is automatically created by <em><a href="g.parser.html">g.parser</a></em>
  324. so that the <tt>--verbose</tt> or <tt>--quiet</tt> flags will be inherited
  325. by dependent modules as the script runs.</dd>
  326. <dt>GRASS_REGION</dt>
  327. <dd>[libgis]<br>
  328. override region settings, separate parameters with a ";". Format
  329. is the same as in the WIND region settings file. Otherwise use is the same as
  330. WIND_OVERRIDE.</dd>
  331. <dt>WIND_OVERRIDE</dt>
  332. <dd>[libgis]<br>
  333. it causes programs to use the specified named region (created with
  334. e.g. <tt>g.region save=...</tt>) to be used as the current region, instead of
  335. the region from the WIND file.<br><br>
  336. This allows programs such as the GUI to run external commands on an
  337. alternate region without having to modify the WIND file then change it
  338. back afterwards.</dd>
  339. </dl>
  340. <a name="gisenv"></a>
  341. <h2>List of selected GRASS gisenv variables</h2>
  342. <blockquote>
  343. [ Use <em><a href="g.gisenv.html">g.gisenv</a></em> to get/set/unset/change them ]
  344. </blockquote>
  345. <dl>
  346. <dt>DEBUG</dt>
  347. <dd>[entire GRASS]<br>
  348. sets level of debug message output (0: no debug messages)
  349. <div class="code"><pre>
  350. g.gisenv set=DEBUG=0
  351. </pre></div>
  352. <dt>WX_DEBUG</dt>
  353. <dd>[wxGUI]<br>
  354. sets level of debug message output for <em><a href="wxGUI.html">wxGUI</a></em> (0: no debug messages, 1-5 debug levels)
  355. <dt>GISDBASE</dt>
  356. <dd>initial database</dd>
  357. <dt>GIS_LOCK</dt>
  358. <dd>lock ID to prevent parallel GRASS use,
  359. <br>process id of the start-up shell script</dd>
  360. <dt>GRASS_DB_ENCODING</dt>
  361. <dd>[d.what.vect/forms library]<br>
  362. encoding of query form (utf-8, ascii, iso8859-1, koi8-r)</dd>
  363. <dt>GUI</dt>
  364. <dd>either <tt>text</tt> or <tt>gui</tt> to define non-/graphical startup.
  365. <br><br> Can also specify the name of the GUI to use,
  366. e.g. <tt>wxpython</tt>
  367. (<em><a href="wxGUI.html">wxGUI</a></em>). Also exists as a shell
  368. environment variable. If this shell variable exists at GRASS
  369. startup, it will determine the GUI used. If it is not defined
  370. startup will default to the last GUI used.</dd>
  371. <dt>LOCATION</dt>
  372. <dd>full path to location directory</dd>
  373. <dt>LOCATION_NAME</dt>
  374. <dd>initial location name</dd>
  375. <dt>MAPSET</dt>
  376. <dd>initial mapset</dd>
  377. <dt>OVERWRITE</dt>
  378. <dd>[all modules]<br>
  379. toggles map overwrite.
  380. <ul>
  381. <li>0 - maps are protected (default),</li>
  382. <li>1 - maps with identical names will be overwritten.</li>
  383. </ul>
  384. This variable is automatically created
  385. by <em><a href="g.parser.html">g.parser</a></em> so that the
  386. <tt>--overwrite</tt> option will
  387. be inherited by dependent modules as the script runs. Setting either the
  388. GRASS_OVERWRITE environment variable or the OVERWRITE gisenv variable detailed
  389. below will cause maps with identical names to be overwritten.</dd>
  390. </dl>
  391. <h2>GRASS-related Files</h2>
  392. <dl>
  393. <dt><tt>$HOME/.grass7/rc</tt></dt>
  394. <dd>stores the GRASS gisenv variables (not shell environment variables)</dd>
  395. <dt><tt>$HOME/.grass7/bashrc</tt></dt>
  396. <dd>stores the shell environment variables (Bash only)</dd>
  397. <dt><tt>$HOME/.grass7/env.bat</tt></dt>
  398. <dd>stores the shell environment variables (MS Windows only)</dd>
  399. <dt><tt>$HOME/.grass7/login</tt></dt>
  400. <dd>stores the DBMI passwords in this hidden file.
  401. Only the file owner can access this file.</dd>
  402. <dt><tt>$HOME/GIS_ERROR_LOG</tt></dt>
  403. <dd>if this file exists then all GRASS error and warning messages are
  404. logged here. Applies to current user. To generate the file, use:
  405. <tt>touch $HOME/GIS_ERROR_LOG</tt><br>
  406. See also GIS_ERROR_LOG variable.</dd>
  407. </dl>
  408. <h2>SEE ALSO</h2>
  409. <em>
  410. <a href="g.gisenv.html">g.gisenv</a>,
  411. <a href="g.parser.html">g.parser</a>
  412. </em>
  413. <p>
  414. <i>Last changed: $Date$</i>