variables(1)
π variables(1) β GRASS variables and environment variables π
okay bestie, sit down, we're doing the GRASS GIS User's Manual thing and honestly this one is a whole vibe. π
A variable in scripting is a symbolic name that holds data which can be used and modified during script execution. Variables allow scripts to store and manipulate values dynamically, making them more flexible and reusable. fr fr, they're the main character of reusability. In GRASS GIS, there are two types of variables:
- shell environment variables,
- GRASS gisenv variables.
And there are a number of shell environment variable groups:
- variables for rendering
- variables for internal use
Note: Any setting which needs to be modifiable by a GRASS module (e.g.MONITORbyd.mon) has to be a GRASS gisenv variable. like⦠it's not optional bestie, it HAS to be gisenv.
πΈ Setting shell environment variables πΈ
Setting shell environment variables depends on the shell being used:
Bash:
export VARIABLE=value
Csh:
setenv VARIABLE value
Cmd.exe (Windows):
set VARIABLE=value
To set up shell environment variables permanently:
- To get personal BASH shell definitions (aliases, color listing option, ...) into GRASS, store them in:
$HOME/.grass8/bashrc - To get personal CSH shell definitions (aliases, color listing option, ...) into GRASS, store them in:
$HOME/.grass8/cshrc
β¨ Setting GRASS gisenv variables β¨
Use g.gisenv within GRASS. This permanently predefines GRASS variables in the $HOME/.grass8/rc file (Linux, Mac, BSD, ...) or in the %APPDATA%\Roaming\GRASS8\rc file (Windows) after the current GRASS session is closed.
Usage:
g.gisenv set="VARIABLE=VALUE"
It looks unusual with two equals signs, but g.gisenv serves dual duty for getting and setting GRASS variables. two jobs, one icon π
If the user just specifies a variable name, it defaults to get mode. For example:
g.gisenv MAPSET
PERMANENT
π¦ List of selected (GRASS related) shell environment variables π¦
[ To be set from the terminal shell or startup scripts ]
GISBASEβ directory where GRASS lives. This is set automatically by the startup script. she sets herself, no need to lift a finger.GISRCβ name of$HOME/.grass8/rcfile. Defines the system wide value when starting a GRASS session. Within a GRASS session, a temporary copy of this file will be used.GRASS_ADDON_PATH[grass startup script, g.extension] β specifies additional path(s) containing local and/or custom GRASS modules extra to the standard distribution.GRASS_ADDON_BASE[grass startup script] β allows specifying additionalGISBASEfor local GRASS modules (normally installed as GRASS Addons byg.extensionmodule) extra to standard distribution. The default on GNU/Linux is$HOME/.grass8/addons, on MS Windows%APPDATA%\Roaming\GRASS8\addons.GRASS_ADDON_ETC[libgis, g.findetc] β specify paths where support files (etc/) may be found external to standard distribution.GRASS_COMPATIBILITY_TEST[libgis] β By default it is not possible to run C modules with a libgis that has a differentGIS_H_VERSION, the compatibility test will exit with a fatal error. Setting this variable to0(zero) withGRASS_COMPATIBILITY_TEST=0allows the test to be passed with a warning. she's strict but she can be negotiated with.GRASS_COMPRESSOR[libraster] β the compression method for new raster maps can be set with the environment variableGRASS_COMPRESSOR. Supported methods areRLE,ZLIB,LZ4,BZIP2, andZSTD. The default isZSTDif available, otherwiseZLIB, which can be changed with e.g.GRASS_COMPRESSOR=ZSTD, granted that GRASS has been compiled with the requested compressor. Compressors that are always available areRLE,ZLIB, andLZ4. The compressorsBZIP2andZSTDmust be enabled when configuring GRASS for compilation.GRASS_CONFIG_DIR[grass startup script] β specifies root path for GRASS configuration directory. If not specified, the default placement of the configuration directory is used:$HOMEon GNU/Linux,$HOME/Libraryon Mac OS X, and%APPDATA%on MS Windows.GRASS_DB_ENCODING[various modules, wxGUI] β encoding for vector attribute data (utf-8,ascii,iso8859-1,koi8-r)GIS_ERROR_LOGβ If set,GIS_ERROR_LOGshould be the absolute path to the log file (a relative path will be interpreted relative to the process' cwd, not the cwd at the point the user set the variable). If not set,$HOME/GIS_ERROR_LOGis used instead. The file will only be used if it already exists.GRASS_ERROR_MAILβ set to any value to send user mail on an error or warning that happens while stderr is being redirected.GRASS_FONT[display drivers] β specifies the font as either the name of a font from$GISBASE/etc/fontcap(or alternative fontcap file specified byGRASS_FONT_CAP), or alternatively the full path to a FreeType font file.GRASS_ENCODING[display drivers] β the encoding to be assumed for text which is drawn using a freetype font; may be any encoding know to iconv.GRASS_FONT_CAP[g.mkfontcap, d.font, display drivers] β specifies an alternative location (to$GISBASE/etc/fontcap) for the font configuration file.GRASS_FULL_OPTION_NAMES[parser] β Generates a warning ifGRASS_FULL_OPTION_NAMESis set (to anything) and a found string is not an exact match for the given string. she's a perfectionist, respect it.GRASS_GUIβ eithertext(text user interface),gtext(text user interface with GUI welcome screen), orgui(graphical user interface) to define non-/graphical startup. Can also specify the name of the GUI to use, e.g.wxpython(wxGUI). Also exists as a GRASS gisenv variable (see below). If this shell variable exists at GRASS startup, it will determine the GUI used. If it is not defined startup will default to the last GUI used.GRASS_HTML_BROWSER[init.sh, wxgui] β defines name of HTML browser. For most platforms this should be an executable in yourPATH, or the full path to an executable.
Mac OS X runs applications differently from the CLI. Therefore, GRASS_HTML_BROWSER should be the application's signature, which is a domain-like name, just reversed, i.e. com.apple.Safari. To find an application's signature, type the following in a Terminal (fill in the path to the application you are interested in, for example: /Applications/Safari.app):
grep -A 1 "CFBundleIdentifier"
/path/to/application.app/Contents/Info.plist
The signature is the <string> following the <key>, without the bracketing <string> tags.
GRASS_INT_ZLIB[libraster] β if the environment variableGRASS_INT_ZLIBexists and has the value0, new compressed integer (CELLtype) raster maps will be compressed usingRLEcompression.
If the variable doesn't exist, or the value is non-zero, zlib compression will be used instead. Such rasters will have a compressed value of 2 in the cellhd file.
Obviously, decompression is controlled by the raster's compressed value, not the environment variable.
GRASS_ZLIB_LEVEL[libgis] β if the environment variableGRASS_ZLIB_LEVELexists and its value can be parsed as an integer, it determines the compression level used when new compressed raster maps are compressed using zlib compression. This applies to all raster map types (CELL,FCELL,DCELL).
Valid zlib compression levels are -1 to 9. The GRASS_ZLIB_LEVEL=-1 corresponds to the zlib default value (equivalent to GRASS_ZLIB_LEVEL=6). Often GRASS_ZLIB_LEVEL=1 gives the best compromise between speed and compression.
If the variable doesn't exist, or the value cannot be parsed as an integer, zlib's default compression level 6 will be used.
GRASS_MESSAGE_FORMAT[various modules, wxGUI] β it may be set to eitherstandard- sets percentage output and message formatting style to standard formatting,gui- sets percentage output and message formatting style to GUI formatting,silent- disables percentage output and error messages,plain- sets percentage output and message formatting style to ASCII output without rewinding control characters.
GRASS_MOUSE_BUTTON[various modules] β swaps mouse buttons for two-button or left-handed mice. Its value has three digits1,2, and3, which represent default left, middle, and right buttons respectively. Setting to132will swap middle and right buttons. Note that this variable should be set before a display driver is initialized (e.g.,d.mon x0). set it early or she won't hear you.GRASS_PAGER[various modules] β it may be set to eitherless,more, orcat.GRASS_PERL[used during install process for generating man pages] β set Perl with path.GRASS_PROXY[used during addon install/reinstall process for generating man pages (download commit from GitHub API server and remote modules.xml file)] β set the proxy with:GRASS_PROXY="http=<value>,ftp=<value>".GRASS_SKIP_MAPSET_OWNER_CHECKβ By default it is not possible to work withMAPSETs that are not owned by current user. Setting this variable to any non-empty value allows the check to be skipped. careful bestie, that's a permission door you're opening.GRASS_SH[shell scripts on Windows] β path to bourne shell interpreter used to run shell scripts.GRASS_SIGSEGV_ON_ERROR[Raise SIGSEGV if an error occurs] β This variable can be set for debugging purpose. The call ofG_fatal_error()will end in a segmentation violation.GDBcan be used to trace the source of the error. yes it crashes on purpose, that's the whole point, iykyk.GRASS_PYTHON[wxGUI, Python Ctypes] β set to override Python executable.
On Mac OS X this should be the pythonw executable for the wxGUI to work.
GRASS_VECTOR_LOWMEM[vectorlib] β If the environment variableGRASS_VECTOR_LOWMEMexists, memory consumption will be reduced when building vector topology support structures. Recommended for creating large vectors.GRASS_VECTOR_OGR[vectorlib, v.external.out] β If the environment variableGRASS_VECTOR_OGRexists and vector output format defined byv.external.outisPostgreSQL, vector data is written byOGRdata provider even the nativePostGISdata provider is available.
okay that's part 1 of this page and there's more coming, so don't go anywhere bestie π
GRASS_VECTOR_EXTERNAL_IMMEDIATE[vectorlib, v.external.out]β if this one exists and the vector output format set byv.external.outis non-native, then vector features get written straight out to the external datasource, like, immediately. π¨ Normally the vector library is a lil procrastinator: it writes output into a temporary vector map in native format, and only when you close the map does it move everything over to the external datasource. But β heads up β if the output vector format is the topological PostGIS format, the vector library writes features immediately to the output database anyway, and in that caseGRASS_VECTOR_EXTERNAL_IMMEDIATEis just ignored. πGRASS_VECTOR_EXTERNAL_IGNORE[vectorlib]β if this exists, the output vector format fromv.external.outis ignored entirely and the format is always native. no cap.GRASS_VECTOR_TEMPORARY[vectorlib]β if this exists, the GRASS vector library operates on temporary vector maps. New vector maps get created in the temporary directory (peep theGRASS_VECTOR_TMPDIR_MAPSETvariable), and existing vector maps will be read from this directory too, if they're found there. You can set it to either:keepβ the temporary vector map is not deleted when closing the map.moveβ the temporary vector map is moved to the current mapset when closing the map.deleteβ the temporary vector map is deleted when closing the map.
Default value is keep. And note that temporary vector maps are not visible to the user via g.list or wxGUI β they're used internally by the GRASS modules and deleted automatically when the GRASS session is quited. π
GRASS_VECTOR_TMPDIR_MAPSET[vectorlib]β by default the GRASS temporary directory lives in$LOCATION/$MAPSET/.tmp/$HOSTNAME. IfGRASS_VECTOR_TMPDIR_MAPSETis set to'0', the temporary directory lives inTMPDIRinstead (that's the environmental variable defined by the user, or by the GRASS initialization script if you didn't give one).
Important note: this variable is currently used only in the vector library. In other words, the variable is ignored by the raster or raster3d library. π
GRASS_VECTOR_TOPO_DEBUG[vectorlib, v.generalize]β if this exists,v.generalizeruns in an extremely slow debug mode. π iconic for debugging, tragic for your patience.GRASS_WXBUNDLED[wxGUI]β set it to tell wxGUI that a bundled wxPython will be used. When it's set, the wxGUI will not check the wxPython version, because that check is incompatible with a bundled wxPython. It's up to the packager to make sure a compatible wxPython version is bundled. πGRASS_WXVERSION[wxGUI]β set it to tell wxGUI which version of wxPython to use. When set, wxGUI selects the given wxPython version. Super useful when you've got multiple versions of wxPython installed and you wanna run wxGUI with a non-default one. β¨GRASS_XTERM[lib/init/grass-xterm-wrapper, lib/init/grass-xterm-mac]β set it to any value (likerxvt,aterm,gnome-terminal,konsole) to substitute'x-terminal-emulator'or'xterm'. The Mac OS X app startup defaults to an internal'$GISBASE/etc/grass-xterm-mac', which emulates the necessary xterm functionality in Terminal.app. πGRASS_UI_TERMβ set to any value to use the terminal based parser.GRASS_VERSIONβ reports the current version number (used by the R-stats interface etc). Should not be changed by user. hands off bestie πGRASS_NO_GLX_PBUFFERS[nviz]β set to any value to disable the use of GLX Pbuffers.GRASS_NO_GLX_PIXMAPS[nviz]β set to any value to disable the use of GLX Pixmaps.OMP_NUM_THREADS[OpenMP]β if OpenMP support is enabled, this limits the number of threads. The default is set to the number of CPUs on the system. Setting it to'1'effectively disables parallel processing.TMPDIR,TEMP,TMP[Various GRASS GIS commands and wxGUI]β the default wxGUI temporary directory is chosen from a platform-dependent list, but you can control which directory gets picked by setting one of theTMPDIR,TEMPorTMPenvironment variables. So the wxGUI uses$TMPDIRif it's set, then$TEMP, otherwise/tmp. π«Ά
π List of selected GRASS environment variables for rendering π
[ In addition to those which are understood by specific GRASS display drivers, the following variables affect rendering. ]
GRASS_RENDER_IMMEDIATEβ tells the display library which driver to use. Possible values:cairo,png,ps,htmlordefault. Default display driver iscairo(if available) otherwisepng.GRASS_RENDER_WIDTHβ defines the width of the output image (default is640).GRASS_RENDER_HEIGHTβ defines the height of the output image (default is480).GRASS_RENDER_FILEβ the name of the resulting image file.GRASS_RENDER_FRAMEβ contains 4 coordinates,top,bottom,left,right(pixel values) with respect to the top left corner of the output image, defining the initial frame.GRASS_RENDER_LINE_WIDTHβ defines default line width.GRASS_RENDER_TEXT_SIZEβ defines default text size.GRASS_RENDER_COMMANDβ external command called by the display library to render data (see the example in the display drivers page for details). Currently only Python scripts are supported. For specific driver-related variables see:- Cairo display driver
- PNG display driver
- PS (Postscript) display driver
- HTML display driver
π«§ List of selected internal GRASS environment variables π«§
[ These variables are intended for internal use only by the GRASS software, to facilitate communication between the GIS engine, GRASS scripts, and the GUI. The user should not set these in a GRASS session. They are meant to be set locally for specific commands. ]
GRASS_OVERWRITE[all modules]β toggles map overwrite.0β maps are protected (default),1β maps with identical names will be overwritten.
This variable is automatically created by g.parser so that the --overwrite option will be inherited by dependent modules as the script runs. Setting either the GRASS_OVERWRITE environment variable or the OVERWRITE gisenv variable detailed below will cause maps with identical names to be overwritten. π₯
GRASS_VERBOSE[all modules]β toggles verbosity level.-1β complete silence (also errors and warnings are discarded)0β only errors and warnings are printed1β progress and important messages are printed (percent complete)2β all module messages are printed3β additional verbose messages are printed
This variable is automatically created by g.parser so that the --verbose or --quiet flags will be inherited by dependent modules as the script runs.
GRASS_REGION[libgis]β override region settings, separate parameters with a";". Format is the same as in theWINDregion settings file. Otherwise use is the same asWIND_OVERRIDE.WIND_OVERRIDE[libgis]β it causes programs to use the specified named region (created with e.g.g.region save=...) as the current region, instead of the region from theWINDfile. This lets programs like the GUI run external commands on an alternate region without having to modify theWINDfile and then change it back afterwards. π§
π List of selected GRASS gisenv variables π
[ Use g.gisenv to get/set/unset/change them ]
DEBUG[entire GRASS]β sets level of debug message output (0: no debug messages)
g.gisenv set=DEBUG=0
WX_DEBUG[wxGUI]β sets level of debug message output for wxGUI (0: no debug messages,1-5debug levels)GISDBASEβ initial databaseGIS_LOCKβ lock ID to prevent parallel GRASS use, process id of the start-up shell scriptGUIβ SeeGRASS_GUIenvironmental variable for details.LOCATIONβ full path to project (previously called location) directoryLOCATION_NAMEβ initial project nameMAPSETβ initial mapsetMEMORYMB[entire GRASS with focus on raster related data processing]β sets the maximum memory to be used (in MB), i.e. the cache size for raster rows
# set to 6 GB (default: 300 MB)
g.gisenv set="MEMORYMB=6000"
NPROCSβ sets the number of threads for parallel computing
# set to use 12 threads (default: 1)
g.gisenv set="NPROCS=12"
OVERWRITE[all modules]β toggles map overwrite.0β maps are protected (default),1β maps with identical names will be overwritten.
This variable is automatically created by g.parser so that the --overwrite option will be inherited by dependent modules as the script runs. Setting either the GRASS_OVERWRITE environment variable or the OVERWRITE gisenv variable detailed below will cause maps with identical names to be overwritten.
πΈ GRASS-related Files πΈ
$HOME/.grass8/rcβ stores the GRASS gisenv variables (not shell environment variables)$HOME/.grass8/bashrcβ stores the shell environment variables (Bash only)$HOME/.grass8/env.batβ stores the shell environment variables (MS Windows only)$HOME/.grass8/loginβ stores the DBMI passwords in this hidden file. Only the file owner can access this file. π$HOME/GIS_ERROR_LOGβ if this file exists then all GRASS error and warning messages are logged here. Applies to current user. To generate the file, use:
touch $HOME/GIS_ERROR_LOG
See also GIS_ERROR_LOG variable. Note: On MS Windows the files are stored in %APPDATA%.
π SEE ALSO π
g.gisenv, g.parser
πΎ SOURCE CODE πΎ
Available at: GRASS variables and environment variables source code (history)
Accessed: Saturday Jan 17 05:40:17 2026
Main index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's a wrap bestie π you just read the whole variables(1) page from the GRASS GIS 8.4.2 Reference Manual β go forth and set your env vars responsibly, and remember: the user should not be setting the internal ones, iykyk. β¨π¦π
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms