variables.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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> (text user interface), <tt>gtext</tt> (text
  115. user interface with GUI welcome screen), or <tt>gui</tt> (graphical
  116. user interface) to define non-/graphical startup. Can also specify
  117. the name of the GUI to use, e.g. <tt>wxpython</tt>
  118. (<em><a href="wxGUI.html">wxGUI</a></em>). Also exists as a GRASS
  119. gisenv variable (see below). If this shell variable exists at GRASS
  120. startup, it will determine the GUI used. If it is not defined
  121. startup will default to the last GUI used.</dd>
  122. <dt>GRASS_HTML_BROWSER</dt>
  123. <dd>[init.sh, wxgui]<br> defines name of HTML browser. For most
  124. platforms this should be an executable in your PATH, or the full
  125. path to an executable.<br> Mac OS X runs applications differently
  126. from the CLI. Therefore, GRASS_HTML_BROWSER should be the
  127. application's signature, which is a domain-like name, just
  128. reversed, i.e. com.apple.Safari. To find an application's
  129. signature, type the following in a Terminal (fill in the path to
  130. the application you are interested in, for example:
  131. /Applications/Safari.app):<br> &nbsp; &nbsp; <code>grep -A 1
  132. &quot;CFBundleIdentifier&quot;</code> <i>/path/to/application.app</i><code>/Contents/Info.plist</code><br>
  133. &nbsp; The signature is the &lt;string&gt; following the
  134. &lt;key&gt;, without the bracketing &lt;string&gt; tags.</dd>
  135. <dt>GRASS_INT_ZLIB</dt>
  136. <dd>[libgis]<br> if the environment variable GRASS_INT_ZLIB exists,
  137. new compressed <i>integer</i> (CELL type) raster maps will be compressed
  138. using zlib instead of RLE compression. Such rasters will have a <tt>compressed</tt>
  139. value of 2 in the cellhd file.
  140. <br><br>
  141. Obviously, decompression is controlled by the
  142. raster's <tt>compressed</tt> value, not the environment variable.</dd>
  143. <dt>GRASS_MESSAGE_FORMAT</dt>
  144. <dd>[various modules, wxGUI]<br>
  145. it may be set to either
  146. <ul>
  147. <li><tt>standard</tt> - sets percentage output and message
  148. formatting style to standard formatting,</li>
  149. <li><tt>gui</tt> - sets percentage output and message formatting
  150. style to GUI formatting,</li>
  151. <li><tt>silent</tt> - disables percentage output and error
  152. messages,</li>
  153. <li><tt>plain</tt> - sets percentage output and message
  154. formatting style to ASCII output without rewinding control
  155. characters.</li>
  156. </ul></dd>
  157. <dt>GRASS_MOUSE_BUTTON</dt>
  158. <dd>[various modules]<br> swaps mouse buttons for two-button or
  159. left-handed mice. Its value has three digits 1, 2, and 3, which
  160. represent default left, middle, and right buttons
  161. respectively. Setting to <tt>132</tt> will swap middle and right
  162. buttons. Note that this variable should be set before a display
  163. driver is initialized (e.g.,
  164. <tt>d.mon x0</tt>).</dd>
  165. <dt>GRASS_PAGER</dt>
  166. <dd>[various modules]<br>
  167. it may be set to either <tt>less</tt>, <tt>more</tt>, or <tt>cat</tt>.</dd>
  168. <dt>GRASS_PERL</dt>
  169. <dd>[used during install process for generating man pages]<br>
  170. set Perl with path.</dd>
  171. <dt>GRASS_RND_SEED</dt>
  172. <dd>set random seed
  173. for <em><a href="r.mapcalc.html">r.mapcalc</a></em> rand()
  174. function.</dd>
  175. <dt>GRASS_SKIP_MAPSET_OWNER_CHECK</dt>
  176. <dd>By default it is not possible to work with MAPSETs that are
  177. not owned by current user. Setting this variable to any non-empty value
  178. allows the check to be skipped.</dd>
  179. <dt>GRASS_SH</dt>
  180. <dd>[shell scripts on Windows]<br>
  181. path to bourne shell interpreter used to run shell scripts.</dd>
  182. <dt>GRASS_SIGSEGV_ON_ERROR</dt>
  183. <dd>Raise SIGSEGV if an error occures]<br>
  184. This variable can be set for debugging purpose. The call
  185. of G_fatal_error() will end in a segmentation violation. GDB can be used
  186. to trace the source of the error.</dd>
  187. <dt>GRASS_PYTHON</dt>
  188. <dd>[wxGUI, Python Ctypes]<br>
  189. set to override Python executable.<br>
  190. On Mac OS X this should be the <tt>pythonw</tt> executable for the
  191. wxGUI to work.</dd>
  192. <dt>GRASS_VECTOR_LOWMEM</dt>
  193. <dd>[vectorlib]<br>
  194. If the environment variable GRASS_VECTOR_LOWMEM exists, memory
  195. consumption will be reduced when building vector topology
  196. support structures. Recommended for creating large vectors.</dd>
  197. <dt>GRASS_VECTOR_OGR</dt>
  198. <dd>[vectorlib, v.external.out]<br> If the environment variable
  199. GRASS_VECTOR_OGR exists and vector output format defined
  200. by <em><a href="v.external.out.html">v.external.out</a></em> is
  201. PostgreSQL, vector data is written by OGR data provider even
  202. the native PostGIS data provider is available.</dd>
  203. <dt>GRASS_VECTOR_EXTERNAL_IMMEDIATE</dt>
  204. <dd>[vectorlib, v.external.out]<br> If the environment variable
  205. GRASS_VECTOR_EXTERNAL_IMMEDIATE exists and vector output format
  206. defined
  207. by <em><a href="v.external.out.html">v.external.out</a></em> is
  208. non-native, vector features are written to output external
  209. datasource immediately. By default, the vector library writes
  210. output data to a temporary vector map in native format and when
  211. closing the map, the features are transfered to output external
  212. datasource. Note: if output vector format is topological PostGIS
  213. format, then the vector library writes features immediately to output
  214. database (in this case GRASS_VECTOR_EXTERNAL_IMMEDIATE is ignored).</dd>
  215. <dt>GRASS_VECTOR_EXTERNAL_IGNORE</dt>
  216. <dd>[vectorlib]<br> If the environment variable
  217. GRASS_VECTOR_EXTERNAL_IGNORE exists, output vector format defined
  218. by <em><a href="v.external.out.html">v.external.out</a></em> is
  219. ignored. The format is always native.</dd>
  220. <dt>GRASS_VECTOR_TEMPORARY</dt>
  221. <dd>[vectorlib]<br> If the environment variable
  222. GRASS_VECTOR_TEMPORARY exists, vector library will operate with
  223. temporary vector maps. New vector maps will be created
  224. in <tt>$MAPSET/.tmp/$HOSTNAME/vector</tt>, existing vector maps
  225. will be read also from this directory. Note that temporary vector
  226. maps are not visible to the user
  227. via <em><a href="g.list.html">g.list</a></em>. They are used
  228. internally by the GRASS modules and deleted automatically when the
  229. map is closed or GRASS session quited. Note that this variable is
  230. dedicated for internal use only.
  231. </dd>
  232. <dt>GRASS_WXBUNDLED</dt>
  233. <dd>[wxGUI]<br>
  234. set to tell wxGUI that a bundled wxPython will be used.<br>
  235. When set, the wxGUI will not check the wxPython version, as this
  236. function is incompatible with a bundled wxPython. It is up to the
  237. packager to make sure that a compatible wxPython version is bundled.</dd>
  238. <dt>GRASS_XTERM</dt>
  239. <dd>[lib/init/grass-xterm-wrapper, lib/init/grass-xterm-mac]<br>
  240. set to any value (e.g. rxvt, aterm, gnome-terminal, konsole) to
  241. substitute 'x-terminal-emulator' or 'xterm'. The Mac OS X app
  242. startup defaults to an internal '$GISBASE/etc/grass-xterm-mac',
  243. which emulates the necessary xterm functionality in
  244. Terminal.app.</dd>
  245. <dt>GRASS_UI_TERM</dt>
  246. <dd>set to any value to use the terminal based parser.</dd>
  247. <dt>GRASS_VERSION</dt>
  248. <dd>reports the current version number (used by R-stats interface etc);
  249. should not be changed by user.</dd>
  250. <dt>GRASS_NO_GLX_PBUFFERS</dt>
  251. <dd>[nviz]<br>
  252. set to any value to disable the use of GLX Pbuffers.</dd>
  253. <dt>GRASS_NO_GLX_PIXMAPS</dt>
  254. <dd>[nviz]<br>
  255. Set to any value to disable the use of GLX Pixmaps.</dd>
  256. <dt>OMP_NUM_THREADS</dt>
  257. <dd>[OpenMP]<br>
  258. If OpenMP support is enabled this limits the number of threads.
  259. The default is set to the number of CPUs on the system.
  260. Setting to '1' effectively disables parallel processing.</dd>
  261. </dl>
  262. <a name="rendering"></a>
  263. <h3>List of selected GRASS environment variables for rendering</h3>
  264. <blockquote>
  265. [ In addition to those which are understood by specific <em>GRASS display
  266. drivers</em>, the following variables affect rendering. ]
  267. </blockquote>
  268. <dl>
  269. <dt>GRASS_RENDER_IMMEDIATE</dt>
  270. <dd>tells the display library which driver to use; possible
  271. 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>
  272. or <em><a href="htmldriver.html">html</a></em></dd>
  273. <dt>GRASS_WIDTH</dt>
  274. <dd>defines the width of output image (default is 640).</dd>
  275. <dt>GRASS_HEIGHT</dt>
  276. <dd>defines the height of output image (default is 480).</dd>
  277. <dt>GRASS_FRAME</dt>
  278. <dd>contains 4 coordinates, <em>top,bottom,left,right</em> (pixel values), defining the initial frame.</dd>
  279. <dt>GRASS_LINE_WIDTH</dt>
  280. <dd>defines default line width.</dd>
  281. <dt>GRASS_TEXT_SIZE</dt>
  282. <dd>defines default text size.</dd>
  283. </dl>
  284. For specific driver-related variables see:
  285. <ul>
  286. <li><em><a href="cairodriver.html">Cairo driver</a></em></li>
  287. <li><em><a href="pngdriver.html">PNG driver</a></em></li>
  288. <li><em><a href="psdriver.html">PS (Postscript) driver</a></em></li>
  289. <li><em><a href="htmldriver.html">HTML driver</a></em></li>
  290. </ul>
  291. <a name="internal"></a>
  292. <h3>List of selected internal GRASS environment variables</h3>
  293. <blockquote>
  294. [ These variables are intended <b>for internal use only</b> by the GRASS
  295. software to facilitate communication between the GIS engine, GRASS scripts,
  296. and the GUI.
  297. The user should not set these in a GRASS session. They are meant to be set
  298. locally for specific commands. ]
  299. </blockquote>
  300. <dl>
  301. <dt>GRASS_OVERWRITE</dt>
  302. <dd>[all modules]<br>
  303. toggles map overwrite.
  304. <ul>
  305. <li>0 - maps are protected (default),</li>
  306. <li>1 - maps with identical names will be overwritten.</li>
  307. </ul>
  308. This variable is automatically created
  309. by <em><a href="g.parser.html">g.parser</a></em> so that the
  310. <tt>--overwrite</tt> option will
  311. be inherited by dependent modules as the script runs. Setting either the
  312. GRASS_OVERWRITE environment variable or the OVERWRITE gisenv variable detailed
  313. below will cause maps with identical names to be overwritten.</dd>
  314. <dt>GRASS_VERBOSE</dt>
  315. <dd>[all modules]<br>
  316. toggles verbosity level
  317. <ul>
  318. <li>-1 - complete silence (also errors and warnings are discarded)</li>
  319. <li>0 - only errors and warnings are printed</li>
  320. <li>1 - progress and important messages are printed (percent complete)</li>
  321. <li>2 - all module messages are printed</li>
  322. <li>3 - additional verbose messages are printed</li>
  323. </ul>
  324. This variable is automatically created by <em><a href="g.parser.html">g.parser</a></em>
  325. so that the <tt>--verbose</tt> or <tt>--quiet</tt> flags will be inherited
  326. by dependent modules as the script runs.</dd>
  327. <dt>GRASS_REGION</dt>
  328. <dd>[libgis]<br>
  329. override region settings, separate parameters with a ";". Format
  330. is the same as in the WIND region settings file. Otherwise use is the same as
  331. WIND_OVERRIDE.</dd>
  332. <dt>WIND_OVERRIDE</dt>
  333. <dd>[libgis]<br>
  334. it causes programs to use the specified named region (created with
  335. e.g. <tt>g.region save=...</tt>) to be used as the current region, instead of
  336. the region from the WIND file.<br><br>
  337. This allows programs such as the GUI to run external commands on an
  338. alternate region without having to modify the WIND file then change it
  339. back afterwards.</dd>
  340. </dl>
  341. <a name="gisenv"></a>
  342. <h2>List of selected GRASS gisenv variables</h2>
  343. <blockquote>
  344. [ Use <em><a href="g.gisenv.html">g.gisenv</a></em> to get/set/unset/change them ]
  345. </blockquote>
  346. <dl>
  347. <dt>DEBUG</dt>
  348. <dd>[entire GRASS]<br>
  349. sets level of debug message output (0: no debug messages)
  350. <div class="code"><pre>
  351. g.gisenv set=DEBUG=0
  352. </pre></div>
  353. <dt>WX_DEBUG</dt>
  354. <dd>[wxGUI]<br>
  355. sets level of debug message output for <em><a href="wxGUI.html">wxGUI</a></em> (0: no debug messages, 1-5 debug levels)
  356. <dt>GISDBASE</dt>
  357. <dd>initial database</dd>
  358. <dt>GIS_LOCK</dt>
  359. <dd>lock ID to prevent parallel GRASS use,
  360. <br>process id of the start-up shell script</dd>
  361. <dt>GRASS_DB_ENCODING</dt>
  362. <dd>[d.what.vect/forms library]<br>
  363. encoding of query form (utf-8, ascii, iso8859-1, koi8-r)</dd>
  364. <dt>GUI</dt>
  365. <dd>See <tt>GRASS_GUI</tt> environmental variable for details.</dd>
  366. <dt>LOCATION</dt>
  367. <dd>full path to location directory</dd>
  368. <dt>LOCATION_NAME</dt>
  369. <dd>initial location name</dd>
  370. <dt>MAPSET</dt>
  371. <dd>initial mapset</dd>
  372. <dt>OVERWRITE</dt>
  373. <dd>[all modules]<br>
  374. toggles map overwrite.
  375. <ul>
  376. <li>0 - maps are protected (default),</li>
  377. <li>1 - maps with identical names will be overwritten.</li>
  378. </ul>
  379. This variable is automatically created
  380. by <em><a href="g.parser.html">g.parser</a></em> so that the
  381. <tt>--overwrite</tt> option will
  382. be inherited by dependent modules as the script runs. Setting either the
  383. GRASS_OVERWRITE environment variable or the OVERWRITE gisenv variable detailed
  384. below will cause maps with identical names to be overwritten.</dd>
  385. </dl>
  386. <h2>GRASS-related Files</h2>
  387. <dl>
  388. <dt><tt>$HOME/.grass7/rc</tt></dt>
  389. <dd>stores the GRASS gisenv variables (not shell environment variables)</dd>
  390. <dt><tt>$HOME/.grass7/bashrc</tt></dt>
  391. <dd>stores the shell environment variables (Bash only)</dd>
  392. <dt><tt>$HOME/.grass7/env.bat</tt></dt>
  393. <dd>stores the shell environment variables (MS Windows only)</dd>
  394. <dt><tt>$HOME/.grass7/login</tt></dt>
  395. <dd>stores the DBMI passwords in this hidden file.
  396. Only the file owner can access this file.</dd>
  397. <dt><tt>$HOME/GIS_ERROR_LOG</tt></dt>
  398. <dd>if this file exists then all GRASS error and warning messages are
  399. logged here. Applies to current user. To generate the file, use:
  400. <tt>touch $HOME/GIS_ERROR_LOG</tt><br>
  401. See also GIS_ERROR_LOG variable.</dd>
  402. </dl>
  403. <h2>SEE ALSO</h2>
  404. <em>
  405. <a href="g.gisenv.html">g.gisenv</a>,
  406. <a href="g.parser.html">g.parser</a>
  407. </em>
  408. <p>
  409. <i>Last changed: $Date$</i>