Unit 04 - Modules, Region¶
Accessing GRASS modules¶
GRASS GIS is a modular system which consists of several hundreds tools (called “modules”). Modules are accessible from the Layer Manager menu, Modules tab, or from command prompt (Console tab).
Let’s find a tool for clipping cloud mask vector map by Jena city region.
Fig. 27 Searching module in Layer Manager by ‘clip’ keyword. The module which we are looking for is v.clip. Module dialog can be open by Run button.
Note
Module v.clip has been introduce to GRASS in version 7.4.0. In older versions more generic v.overlay module can be used.
Fig. 28 Launching v.clip module from Layer Manager console.
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.clip module.
Fig. 29 GUI dialog for launching v.clip module.
Tip
CLI syntax of modules is shown in GUI dialog statusbar, see Fig. 29. 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
Fig. 30 Clipped clouds mask by Jena city region.
Each GRASS command 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¶
Computation region is a 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.
Important
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). Note that GRASS supports only regular grids.
Fig. 31 2D computation region grid.
Note
For 3D raster data (known as “volumes”) there is an extension to 3D computation grid.
Majority of raster processing GRASS modules (r.*) respect
computational region, there are a few exceptions like import modules
(eg. r.import). On the other hand, the most of vector
processing modules (v.*) ignore computation region completely
since there is no computation grid defined by them.
Computational region can be easily set on existing raster or vector map from Layer Manager.
Fig. 32 Set computational region from raster map.
Note that when setting up computational region from vector map, only extent is adjusted. It’s good idea to align the computational grid based on raster map used for computation (Align computational region to selected map).
Tip
Current computation extent can be displayed in map window.
Fig. 33 Show computation region extent in map display.
Full flexibility for operating with computation region allows g.region module (). Example below:
g.region vector=jena_boundary align=L2A_T32UPB_20170706T102021_B04_10m
Color table¶
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) by using r.colors command.
r.colors map=L2A_T32UPB_20170706T102021_B04_10m color=grey.eq
Tip
Color table can be easily set also from Layer Manager or managed interactively by .
Fig. 34 Set color table from Layer Manager.
Fig. 35 Set ‘grey.eq’ color table.
Fig. 36 Sentinel 4th band with enhanced grey color table.