variables(1grass)
π GRASS variables and environment variables π
okay so bestie, welcome to the variables(1grass) manual! this is the GRASS User's Manual, and we're about to spill all the tea on variables and env vars. π«β¨ a variable in scripting is literally just a symbolic name that holds data which can be used and modified during script execution. variables let scripts store and manipulate values dynamically, making them more flexible and reusable. it's giving main character energy. π
in GRASS, there are two types of variables:
- shell environment variables,
- GRASS gisenv variables.
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. periodt.
π Setting shell environment variables π
setting shell environment variables depends on the shell being used. so like, match your vibe:
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. iykyk. π
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. slay.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 to 0 (zero) withGRASS_COMPATIBILITY_TEST=0allows the test to be passed with a warning.GRASS_COMPRESSOR(libraster) β the compression method for new raster maps can be set with this env var. 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.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_BROWSERshould 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 value 0, new compressed integer (CELLtype) raster maps will be compressed usingRLEcompression. if the variable doesnβt exist, or the value is non-zero,zlibcompression will be used instead. such rasters will have a compressed value of 2 in thecellhdfile. 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 usingzlibcompression. this applies to all raster map types (CELL,FCELL,DCELL). validzlibcompression levels are -1 to 9. theGRASS_ZLIB_LEVEL=-1corresponds to thezlibdefault value (equivalent toGRASS_ZLIB_LEVEL=6). oftenGRASS_ZLIB_LEVEL=1gives 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 either:standard- 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 digits 1, 2, and 3, which represent default left, middle, and right buttons respectively. setting to 132 will swap middle and right buttons. note that this variable should be set before a display driver is initialized (e.g.,d.mon x0).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 remotemodules.xmlfile)) β set the proxy with:GRASS_PROXY="http=<value>,ftp=<value>".GRASS_SKIP_MAPSET_OWNER_CHECKβ by default it is not possible to work with MAPSETs that are not owned by current user. setting this variable to any non-empty value allows the check to be skipped.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. GDB can be used to trace the source of the error.GRASS_PYTHON(wxGUI, Python Ctypes) β set to override Python executable. on Mac OS X this should be thepythonwexecutable 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.outis PostgreSQL, vector data is written by OGR data provider even the native PostGIS data provider is available.
β¨ okay bestie, that's part 1! part 2 is literally right there, keep scrolling π
GRASS_VECTOR_EXTERNAL_IMMEDIATE
[vectorlib, v.external.out]
okay so if this env var exists AND the vector output format that v.external.out set up is non-native, then vector features get written straight to the output external datasource, immediately, no waiting. β¨ By default the vector library is lowkey patient: it writes output data to a temporary vector map in native format first, and only when the map gets closed does it transfer the features over to the external datasource. BUT β note this: if the output vector format is topological PostGIS format, then the vector library writes features immediately to the output database anyway (and in that case GRASS_VECTOR_EXTERNAL_IMMEDIATE is just ignored, bestie, it does nothing π).
GRASS_VECTOR_EXTERNAL_IGNORE
[vectorlib]
If this one exists, the output vector format defined by v.external.out gets ignored entirely. The format is always native. Periodt.
GRASS_VECTOR_TEMPORARY
[vectorlib]
If this exists, the GRASS vector library will operate on temporary vector maps π
. New vector maps get created in the temporary directory (peep the GRASS_VECTOR_TMPDIR_MAPSET variable), and existing vector maps will be read (if found) from this directory too. You can set it to one of these:
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. πΈ
Heads up: temporary vector maps are not visible to the user via g.list or wxGUI. They're used internally by the GRASS modules and get 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. If GRASS_VECTOR_TMPDIR_MAPSET is set to '0', the temporary directory lives in TMPDIR instead (that's the environmental variable defined by the user, or by the GRASS initialization script if you never gave one). π
Important note, no cap: 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.generalize runs in extremely slow debug mode. Like, it's giving glacial. π’ Use it when you're desperate for the debug tea.
GRASS_WXBUNDLED
[wxGUI]
set to tell the wxGUI that a bundled wxPython is gonna be used. When it's set, the wxGUI will not check the wxPython version, because that check is incompatible with a bundled wxPython π ββοΈ. It is up to the packager to make sure that a compatible wxPython version is bundled. iykyk.
GRASS_WXVERSION
[wxGUI]
set to tell the wxGUI which version of wxPython to use. When it's set, the wxGUI will select the version you named. Super useful when you've got multiple versions of wxPython installed and you want to run the wxGUI with a non-default one. π
GRASS_XTERM
[lib/init/grass-xterm-wrapper, lib/init/grass-xterm-mac]
set to any value (e.g. rxvt, 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. cute right?
GRASS_UI_TERM
set to any value to use the terminal based parser. β¨
GRASS_VERSION
reports the current version number (used by R-stats interface etc); should not be changed by user. Leave it alone bb, it's not yours. π«Ά
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 (yes, that's the sad girl setting π).
TMPDIR, TEMP, TMP
[Various GRASS commands and wxGUI]
The default wxGUI temporary directory gets chosen from a platform-dependent list, but you β yes YOU β can control the selection of this directory by setting one of the TMPDIR, TEMP or TMP environment variables. So the priority order is: wxGUI uses $TMPDIR if 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, html or default. Default display driver is cairo (if available) otherwise png. π
GRASS_RENDER_WIDTH
defines the width of output image (default is 640).
GRASS_RENDER_HEIGHT
defines the height of output image (default is 480).
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 example in 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. ]
Bestie. Genuinely. Do not set these in a GRASS session okay? They're internal comms, not your personal playground. π
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 the WIND region settings file. Otherwise use is the same as WIND_OVERRIDE.
WIND_OVERRIDE
[libgis]
it causes programs to use the specified named region (created with e.g. g.region save=...) to be used as the current region, instead of the region from the WIND file. πΈ This allows programs such as the GUI to run external commands on an alternate region without having to modify the WIND file then change it back afterwards. main character energy tbh.
GRASS_MASK
[libgis]
use the raster map specified by name as mask, instead of a raster called MASK in the current mapset. π¦
β¨ 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-5 debug levels)
GISDBASE
initial database
GIS_LOCK
lock ID to prevent parallel GRASS use, process id of the start-up shell script
GUI
See GRASS_GUI environmental variable for details.
LOCATION
full path to project (previously called location) directory
LOCATION_NAME
initial project name
MAPSET
initial mapset
MEMORYMB
[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: Tuesday Sep 08 11:53:42 2026
Main index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page bestie, you ate it π
β¨ the source here is the GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team, and the page itself is from variables(1grass), GRASS version 8.5.0 β go forth and configure responsibly, mwah ππ¦π
π¦ where this page comes from
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· 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