Unit 04 - Modules, Region

Accessing GRASS modules

GRASS is a modular system which consists of several hundreds tools (called “modules”). Modules are accessible from the Layer Manager menu, Modules tab, and from command prompt (Console tab).

Let’s find a tool for clipping cloud mask vector map by Jena city area.


Fig. 30 Searching module in Layer Manager by ‘clip’ keyword.

The module which we are looking for is v.overlay.


Fig. 31 Launching v.overlay module from Layer Manager console.


Since GRASS 7.4.0 there is a better choice for vector clipping than generic v.overlay module: v.clip.

The commands (modules) can be called using GUI dialogs, from command line (Console or “real” terminal), or by using Python API (see Unit 10 - Python intro). Figure bellow shows GUI dialog of v.overlay module. The corresponding command for console would be:

v.overlay ainput=MaskFeature binput=jena_boundary operator=and output=jena_clouds

Fig. 32 GUI dialog for launching v.overlay module (syntax for CLI displayed in statusbar).


Fig. 33 Clipped clouds mask by Jena city area.

All GRASS commands start by a prefix. This prefix groups modules into several sections, see table below.

prefix section description
db. database attribute data management
d. display display commands
g. general generic commands
i. imagery imagery data processing
ps. postscript map outputs
r. raster 2D raster data processing
r3. raster3D 3D raster data processing
v. vector 2D/3D vector data processing

Computational region

Computation region is key issue in GRASS raster processing. Unlike GIS software like Esri ArcGIS which sets computation region based on input data, GRASS is leaving this operation to the user.


The user must define computation region before any raster computation is performed!

Computational region is defined by extent (north, south, east, west) and by spatial resolution in the both directions (east-west, north-south). GRASS supports only regular grids.


Fig. 34 2D computation region grid.


For 3D raster data there is an extension to 3D computation grid.

Majority of raster processing modules (r.*) in GRASS respect computational region, there are few exceptions like import modules (r.import). On the other hand, the most of vector processing modules (v.*) ignore computation region completely.

Computational region can be easily set on existing raster or vector map from Layer Manager.


Fig. 35 Set computational region from raster map.

When setting up computational region from vector map, only extent is adjusted. It’s good idea to align a grid based on raster map used for computation (Align computational region to selected map).


Current computation extent can be displayed in map window.


Fig. 36 Show computation region extent in map display.

Full flexibility for operating with computation region allows g.region module.

Color table

With knowledge of computational region let’s enhance color table using histogram equalization (which is influenced by computation region as we already know) by using r.colors.

r.colors map=L2A_T32UPB_20170706T102021_B04_10m color=grey.eq


Color table can be easily set also from Layer Manager or managed interactively by Raster ‣ Manage colors ‣ Manage color rules interactively.


Fig. 37 Set color table from Layer Manager.


Fig. 38 Set ‘grey.eq’ color table.


Fig. 39 Sentinel 4th band with enhanced grey color table.