Unit 04 - Modules, Region

Accessing GRASS modules

GRASS GIS is a modular system which consists of several hundreds tools (“modules” in GRASS terminology). Modules are accessible from the menu, Tools tab, or from command prompt (Console tab).

Let’s find a tool which clips cloud mask vector map by Jena city region.

../_images/modules-tab.png

Fig. 26 Search for a tool by ‘clip’ keyword in Tools tab. The module which we are looking for is v.clip. Module dialog can be open by Run button.

Note

Module v.clip was introduced to GRASS in version 7.4.0. In older versions generic v.overlay module can be used.

../_images/modules-cmd.png

Fig. 27 Launching v.clip module from Console tab.

Tools (modules) can be run from GUI dialogs, from Console tab, or by using Python API (see Unit 10 - Python intro). Figure bellow shows GUI dialog of v.clip module.

../_images/v-clip.png

Fig. 28 GUI dialog for launching v.clip module.

Tip

CLI syntax of modules is shown in GUI dialog statusbar, see Fig. 28. Command can be copied to clipboard by Copy button for later usage.

The corresponding command for console would be:

v.clip input=MaskFeature clip=jena_boundary output=jena_clouds
../_images/jena-clouds.png

Fig. 29 Clipped clouds mask by Jena city region.

Each GRASS module starts 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
t. temporal Temporal data processing
v. vector 2D/3D vector data processing

Computational region

The computational region is a key element in GRASS raster processing. Unlike other GIS software such as Esri ArcGIS which sets the computational region based on input data, GRASS is leaving this operation to the user.

Important

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

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

../_images/region2d.png

Fig. 30 2D computational region grid.

Note

For 3D raster data (known as “volumes”) there is an extension to the 3D computation grid.

The great majority of raster processing modules (r.*) respect the computational region. There are a few exceptions like import modules (eg. r.import). On the other hand, most vector processing modules (v.*) ignore the computational region completely since there is no computation grid defined for them.

The computational region can be easily set on existing raster or vector map from Layer tab.

../_images/comp-region-raster.png

Fig. 31 Set computational region from raster map.

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

Current computation region extent is by default visualized in map window as a red rectangle.

../_images/show-comp-region.png

Fig. 32 Show/Hide computational region extent in map display.

Full flexibility for operating with computational region is allowed via the g.region module (Settings ‣ Computational region ‣ Set region). Example below:

g.region vector=jena_boundary align=L2A_T32UPB_20170706T102021_B04_10m

Color table

The color table of raster maps can be changed by the r.colors command. With knowledge of computational region let’s enhance color table of imported Sentinel band using histogram equalization (which is influenced by computation region as we already know).

../_images/r-colors-menu.png

Fig. 33 Set color table from Layers tab.

Example of command:

r.colors map=L2A_T32UPB_20170706T102021_B04_10m color=grey.eq
../_images/r-colors.png

Fig. 34 Choose the predefined ‘grey.eq’ (enhanced grey scale) color table in the Define tab.

../_images/r-colors-jena.png

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

Tip

Color table set also interactively in the case that predefined color tables do not satisfy user’s needs.