GRASS (Geographic Resources Analysis Support System) is an open source GIS with advanced analysis, modeling, and visualization capabilities. GRASS works as a shell environment or a wxWidgets GUI (using wxPython).
The GRASS main program such as grass
(link) or grass72
(version specific Python script) can:
-c
, create location or mapset (and -e
exit);--exec
, run a GRASS module or a user shell (sh
) /Python (python
) script;-text
, CLI with graphical greetings -gtext
, or GUI (-gui
),<GISDBASE>/<LOCATION_NAME>/<MAPSET>
), or obtained from environment variables (-
).$HOME/.grass7/rc
.Development of GRASS started in 1987 by USA-CERL, a branch of the U.S. Army Corps of Engineers, with initial release in 1984 for Unix. In comparison, Esri's initial product ARC/INFO was released in 1982 as a command line GIS product on minicomputers, and later on UNIX (v5.0) and Windows (v7.1). CERL stopped supporting GRASS in 1995 (v4.1) and the current project leader is Markus Neteler. The current major version GRASS 7 was released in 2015.
Precedence of GRASS configuration:
$HOME/.grass7/
for GRASS 7):
bashrc
, cshrc
, zshrc
, env.bat
, GRASS-related Bash/Csh/Zsh/CMD environment variables;rc
, cache of GRASS GIS environment (gisenv) variables, set by g.gisenv set="VARIABLE=VALUE"
;GRASS does not work very well with zsh, try export SHELL=/bin/bash
before calling grass
.
GRASS-related shell environment variables: Documentation
GISBASE
, GRASS library;GISRC
, file path for GRASS session gisenv values, $HOME/.grass7/rc
for GRASS 7;GRASS_GUI
, type of GRASS user interface;GRASS_PYTHON
, default python in GRASS GUI overiding shell python
;GRASS_HTML_BROWSER
, HTML browser for help pages;GRASS_ADDON_BASE
, GRASS_ADDON_PATH
, extra search paths for repository/local add-on modules;LOCATION
, full path of default GRASS mapset;GISDBASE
, LOCATION_NAME
, MAPSET
, default GRASS database/location/mapset;GRASS_RENDER_IMMEDIATE
, GRASS_RENDER_WIDTH
, GRASS_RENDER_HEIGHT
, GRASS_RENDER_FRAME
, GRASS_RENDER_LINE_WIDTH
, GRASS_RENDER_TEXT_SIZE
, GRASS_RENDER_FILE
, graphical output;GRASS_MESSAGE_FORMAT
, percentage output and message formatting style;GRASS_SH
, bourne shell interpreter used to run shell scripts;GRASS_BATCH_JOB
, shell script to execute at GRASS launch.GRASS GIS environment (gisenv) variables:
DEBUG
, debug message level;GIS_LOCK
, lock ID to prevent concurrent GRASS use, default to the process id of the start-up shell script;OVERWRITE
, allow map overwrite;GUI
;LOCATION
, GISDBASE
, LOCATION_NAME
, MAPSET
;Unlike QGIS, GRASS manages geospatial data under a dedicated directory called a GRASS database. Data in external formats such as Shapefile and GeoTIFF are best maintained in a separate location.
GRASS database hierarchy:
/home/$USER/grassdata/
.PERMANENT/
mapset is reserved for default cartography.Mapset structure by data type:
vector/
, vector maps (each may have coor
, dbin
, hist
, sidx
, topo
);sqlite/
, attribute tables managed by SQLite;cats/
, cell/
, cellhd/
, cell_misc/
, colr/
, fcell/
, hist/
;
WIND
, GRASS region for raster data;grid3/
, 3D raster maps;GRASS topological vector model:
GRASS raster model:
GRASS is set up as a modified shell environment where operations are bundled modules: either as standalone executables written in C, or as Python scripts calling them. Near 400 core modules come with the GRASS distribution; user-created add-on modules are available on its website. Most modules read maps from the GRASS database and write new maps back; other types of outputs are either stored in temporary files or put to the standard streams which can be chained with other programs.
Figure: GRASS 7 Architecture. SourceGRASS Reference Manuals have a complete list of modules: List, Grouped, Graphical.
Module groups not documented: m
, miscellaneous; ps
, PostScript; test
, test;
g
General data management:
g.gisenv
, manage GRASS GIS environment variable.
g.proj
, projection information.
g.region
, computational region.
g.mapset
, mapset search path.
g.copy
, copy data files to the current mapset.
g.extension
, manage add-on modules.
v
v.in.ogr
, imports vector data in OGR supported formats.
v.in.osm
(add-on module), imports OpenStreetMap data.
v.extract
, selects vector objects from an existing vector map and creates a new map.
v.proj
, re-projection.
v.clean
, topological cleaning.
v.generalize
, simplification, smoothing.
v.select
, feature select operations (calling GEOS).
v.overlay
, feature overlay operations.
v.net
, network analysis (shortest path, subnet allocation, cost isoline, travelling salesman).
v.rast.stats
, univariate statistics per vector feature based on a raster map.
v.lrs
, Linear referencing (LRS).
v.db
, attribute table management.
v.colors
, color table of a vector map.
v.transform
, affine transformation (shift, scale and rotate).
r
& 3D Raster r3
r.in.gdal
, import raster data of common formats (GeoTIFF).
r.univar
, univariate analysis.
r.mapcalc
, map calculation.
r.surf
, generate surface map.
r.grow
, grow raster map.
r.tile
, split a raster map into tiles.
Elevation (DEM) analysis:
cost surface: r.cost
, r.walk
;
hydrological modelling: r.watershed
, r.terraflow
, r.flow
, r.drain
, r.fill
;
sight: r.viewshed
;
Energy: r.sun
, r.sunmask
.
Voxel (3D raster) processing: r3.stats
, voxel statistics.
i
i.segment
, unsupervised image classification.
i.pca
, Principal Components Analysis on imagery group.
t
Temporal processing for spatio-temporal data sets (new in GRASS 7).
data types: t.rast
, t.rast3d
, t.vect
(time series aggregation).
animation.
db
Database integration: SQLite (default DB backend), PostgreSQL, MySQL, ODBC, DBF.
db.connect
, database connection.
db.select
, select value(s) from table.
d
Graphic output:
d.vect.thematic
, displays thematic vector map.
OSGeo wiki page on GRASS and Shell
You may include the following in shell scripts to set up a GRASS environment:
export GISBASE=/usr/lib/grass72
export PATH=$GISBASE/bin:$GISBASE/scripts:$PATH
export LD_LIBRARY_PATH=$GISBASE/lib:$LD_LIBRARY_PATH
# path to GRASS settings file
export GISRC=$HOME/.grass7/rc
# use process ID (PID) as lock file number
export GIS_LOCK=$$
Cleanup internal temporary files:
$GISBASE/etc/clean_temp
rm -rf /tmp/grass6-$USER-$GIS_LOCK
If you change the prompt:
PS1_BACKUP=$PS1
export PS1="GRASS> "
# ... do something with GRASS
export PS1=$PS1_BACKUP
GRASS as an open source GIS backbone:
PyGRASS
, GRASS 7 API (scripting via GRASS modules, interface to C libraries); PyWPS
, python web processing service (OGC Web Services).rgrass7
); Using GRASS GIS within a R session (call rgrass7::initGRASS()
).