Unit 08 - Modeler

Graphic Modeler allows creating, editing, and managing complex models in easy-to-use graphical user interface. Using Graphical Modeler, that chain of processes (ie. GRASS modules) can be wrapped into one process (model). The model can be executed repeatedly with slightly different inputs or parameters.

Our first model will be simple as much as possible based on Unit 05 - Perform computation. Actually the model will perform two operations:

  1. set mask based on vector cloud mask file (r.mask) and
  2. compute NDVI (i.vi)

Graphical Modeler can be launched from menu File ‣ Graphical modeler or by grass-modeler-main Graphical Modeler from main toolbar (or alternatively as g.gui.gmodeler module from console).

../_images/gmodeler.png

Fig. 58 Graphical Modeler.

GRASS modules can be added to the model from menu Model ‣ Add command or by grass-module-add Add command (GRASS module) to the model from main toolbar.

../_images/add-module.png

Fig. 59 Add commands (GRASS modules) to the model, in this case r.mask.

After adding r.mask module to the model let’s open its properties dialog by double-click and enter vector map to be used as a mask. Don’t forget to enable inverse mask by -i flag.

../_images/module-props.png

Fig. 60 Define parameters for r.mask, a vector map used for creating a mask.

In similar way will be added to the model second command i.vi (properties dialog for this command is open automatically because there are required options which must be set).

../_images/model-v1.png

Fig. 61 NDVI model version 1.

It’s good idea to set metadata for the model and enable overwriting data produced by model (Model ‣ Model properties).

../_images/model-v1-props.svg

Fig. 62 Define model properties and enable overwriting data produced by model.

Let’s try out our first model. You can run the model repeatedly on different computation regions. You can quickly change current computation region by Set computation region extent interactively from grass-zoom-more Various zoom options in Map Display.

../_images/model-v1-region.png

Fig. 63 Change computation region before running the model.

Important

Before changing the region it’s good idea to remove mask if exists.

r.mask -r

Now let’s run our model by grass-execute Run model. Progress is printed into Command output.

../_images/model-v1-output.png

Fig. 64 Model computation progress.

After redrawing map display grass-layer-redraw Render map (assuming that we have already displayed raster map of NDVI in map display), we should see a difference.

../_images/model-v1-display.png

Fig. 65 New NDVI raster map computed by the model.

Sample model to download: ndvi-v1.gxm