Unit 07 - QGIS loves GRASS¶
Let’s step out of the GRASS GIS environment for a moment. QGIS is a very popular open source GIS package which made a significant progress in the last years. Nowadays it’s used in education, academic environment, but also in commercial settings. In 2002 QGIS started a multiplatform viewer for geospatial data. In the recent years QGIS made important steps for being analytical tool. Beside native algoritms QGIS offers also connection to third-party software packages as SAGA, Orfeo or GRASS GIS. GRASS tools can be run directly from QGIS enviroment without starting GRASS explicitly.
There are two options how to access GRASS tools from QGIS environment:
- generic Processing plugin
- specialized GRASS plugin
Both plugins can be activated from
. Processing plugin is activated by default.Let’s compute NDVI as described in Unit 05 - Raster processing using i.vi
GRASS tool, but in this case directly from QGIS UI. Load into QGIS
input data: Jena city region (geodata/osm/jena_boundary.gpkg
)
and Sentinel bands (red and near-infrared channels) from
geodata/sentinel/sample
.
Processing plugin¶
Processing plugin is a generic toolbox which allows to run tools provided by QGIS or third-party software packages like eg. GRASS. Let’s open i.vi GRASS module.
and search forFig. 46 shows how Processing plugin works. First of all a temporary GRASS location is created by g.proj, input data is linked into temporary location by r.external. Then computation can finally starts by running i.vi module. In the last step output data is exported out of GRASS using r.out.gdal. The resultant GeoTiff file is vizualized in QGIS map window.
GRASS plugin¶
GRASS plugin has been designed to support GRASS as a native processing toolbox. This also includes capability to vizualize data stored in GRASS native format (raster and vector maps located in GRASS locations). And, of course, ability to run any GRASS command with full flexibility of GRASS GIS environment. On the other hand, in contrast to Processing plugin, the GRASS plugin requires at least a basic knowledge of GRASS GIS concepts: locations, mapsets, and control of computational region. In opposite to Processing plugin data created by GRASS plugin are persistent, so accessible also by GRASS GIS itself.
In order to use GRASS plugin, you have to define/create a location and mapset to be entered. New location/mapset can be created by Creating new location (Unit 02). Since there is already GRASS location and mapset prepared in Unit 02 - First steps it can be entered by .
. Creating a new mapset using GRASS plugin is a very similar procedure to creating location/mapset in native GRASS GIS environment, seeAfter specifying GRASS location and mapset, the GRASS tools can be activated from menu
.GRASS plugin offers GUI tool for defining computational region in Region tab. For more advanced operations can be used g.region module.
Let’s search for i.vi GRASS tool in Modules tab.
Tip
GRASS modules can be launched also from GRASS shell as shows the figure below.
By adding a flag –ui to the end of command, a native GRASS GUI dialog appears. In this way other GRASS tools like g.gui.gmodeler (see Unit 08 - Modeler) or a whole GRASS GUI by g.gui can be started. Yes, it seems schizophrenic a bit to start GRASS GUI from GRASS plugin in QGIS environment. Someone can ask, why don’t you use GRASS directly ;-)
Computed output data is stored in the current mapset open by GRASS plugin. Native GRASS data can be directly accessed from QGIS Browser Panel similarly as other data sources, see Fig. 53.