wxGUI.gmodeler(1grass)

๐ŸŒธ wxGUI Graphical Modeler ๐ŸŒธ

okay so bestie, welcome to wxGUI.gmodeler(1grass) โ€” the manual page for the Graphical Modeler, which is a whole wxGUI component and honestly it's giving main character energy ๐Ÿ’…


โœจ DESCRIPTION โœจ

The Graphical Modeler is a wxGUI component that lets you create, edit, and manage simple and complex models through an easy-to-use interface. Like, actually easy. ๐Ÿซถ

So here's the vibe: when you do analytical operations in GRASS, the operations are not isolated โ€” they're part of a chain of operations. And with the Graphical Modeler, you can wrap a whole chain of processes (i.e. GRASS modules) into one single process (i.e. a model). Which means later on, running that model again โ€” even with slightly different inputs or parameters โ€” is so much easier. Obsessed. โœจ

Models represent a programming technique used in GRASS to concatenate single steps together to accomplish a task. And it's genuinely advantageous when the user sees boxes and ovals connected by lines that represent some tasks, rather than seeing lines of coded text. The Graphical Modeler can be used as a custom tool that automates a process. Created models can simplify or shorten a task which can be run many times, and they can also be easily shared with others. ๐ŸŽ€

but important to note, no cap: models cannot perform specified tasks that one cannot also manually perform with GRASS. It is recommended to first develop the process manually, note down the steps (e.g. by using the Copy button in module dialogs) and later replicate them in the model. fr fr.

The Graphical Modeler allows you to:

  • define data items (raster, vector, 3D raster maps)
  • define actions (GRASS commands)
  • define relations between data and action items
  • define loops (e.g. map series) and conditions (if-else statements)
  • define model variables
  • parameterize GRASS commands
  • define intermediate data
  • validate and run model
  • save model properties to a file (GRASS Model File|*.gxm)
  • export model to Python script
  • export model to Python script in the form of a PyWPS process
  • export model to an actinia process
  • export model to image file

๐ŸŽ€ Main dialog ๐ŸŽ€

The Graphical Modeler can be launched from the Layer Manager menu File -> Graphical modeler, or from the main toolbar. It's also available as a stand-alone module g.gui.gmodeler. so many doorways, pick your fave ๐Ÿ’–

The main Graphical Modeler menu contains options which enable the user to fully control the model. Directly under the main menu you'll find a toolbar with buttons (see figure below). The options include:

  1. Create new model
  2. Load model from file
  3. Save current model to file
  4. Export model to image
  5. Export model to a (Python/PyWPS/actinia) script
  6. Add command (GRASS module) to model
  7. Add data to model
  8. Manually define relation between data and commands
  9. Add loop/series to model
  10. Add comment to model
  11. Redraw model canvas
  12. Validate model
  13. Run model
  14. Manage model variables
  15. Model settings
  16. Show manual
  17. Quit Graphical Modeler

Figure: Components of Graphical Modeler menu toolbar.

There's also a lower menu bar in the Graphical modeler dialog where one can manage model items, visualize commands, add or manage model variables, define default values and descriptions. The Script editor dialog window allows seeing and exporting workflows as basic Python scripts, as PyWPS scripts, or as actinia processes. ๐Ÿฆ‹

The rightmost tab of the bottom menu is automatically triggered when the model is activated, and it shows all the steps of running GRASS modeler modules; in the case some errors occur in the calculation process, they are written at that place. so that's where you go snooping when something's acting up ๐Ÿ˜ญ

Figure: Lower Graphical Modeler menu toolbar.


๐Ÿฆ‹ Components of models ๐Ÿฆ‹

The workflow is usually established from four types of diagrams. Input and derived model data are usually represented with oval diagrams. This type of model element stores the path to specific data on the user's disk. It is possible to insert vector data, raster data, database tables, etc. And the type of data is clearly distinguishable in the model by its color. ๐ŸŒˆ

Different model elements are shown in the figures below:

  • (A) raster data:
  • (B) relation:
  • (C) GRASS module:
  • (D) loop:
  • (E) database table:
  • (F) 3D raster data:
  • (G) vector data:
  • (H) disabled GRASS module:
  • (I) comment:

Figure: A model to perform unsupervised classification using MLC (i.maxlik) and SMAP (i.smap).

Another example: Figure: A model to perform estimation of average annual soil loss caused by sheet and rill erosion using The Universal Soil Loss Equation.

Example as part of landslide prediction process: Figure: A model to create parametric maps used by geologists to predict landslides in the area of interest.


โœจ EXAMPLE โœจ

Okay bestie, real talk โ€” this one's a whole glow-up demo ๐Ÿ’…. We're gonna take the zipcodes_wake vector data and the elev_state_500m raster data from the North Carolina sample dataset (that's the original raster and vector data, periodt) and we're gonna compute the average elevation for every zone. The star of the show here is the Graphical Modeler โ€” specifically the way it can automate a whole process so you literally never have to do it by hand again. Obsessed. ๐Ÿซถ


๐ŸŒธ The workflow shown as a series of commands

If you did this the old-fashioned way, in the command console, it looks like this:

# input data import
r.import input=elev_state_500m.tif output=elevation
v.import input=zipcodes_wake.shp output=zipcodes_wake
# computation region settings
g.region vector=zipcodes_wake
# raster statistics (average values), upload to vector map table calculation
v.rast.stats -c map=zipcodes_wake raster=elevation column_prefix=rst method=average
# univariate statistics on selected table column for zipcode map calculation
v.db.univar map=zipcodes_wake column=rst_average
# conversion from vector to raster layer (due to result presentation)
v.to.rast input=zipcodes_wake output=zipcodes_avg use=attr attribute_column=rst_average
# display settings
r.colors -e map=zipcodes_avg color=bgyr
d.mon start=wx0 bgcolor=white
d.barscale style=arrow_ends color=black bgcolor=white fontsize=10
d.rast map=zipcodes_avg bgcolor=white
d.vect map=zipcodes_wake type=boundary color=black
d.northarrow style=1a at=85.0,15.0 color=black fill_color=black width=0 fontsize=10
d.legend raster=zipcodes_avg lines=50 thin=5 labelnum=5 color=black fontsize=10

Like, it works, but it's giving "typing everything every single time" energy and we are not about that life. ๐Ÿ˜ญ


๐ŸŽ€ Defining the workflow in the Graphical Modeler

To turn all of that into an automatic process, press the icon or just type g.gui.gmodeler. The easiest way to insert elements? Drop the whole GRASS command right into the Command field of the GRASS command dialog (peep the figure below, it's iconic). Pro tip from me to you: full text search makes module hunting so much faster, no cap. Then you add the label and the command. And bestie โ€” if you only insert a module name, once you hit the Enter button the module dialog window pops up and you can set all the usual module options (parameters and flags right there). Slay. โœจ

Figure: Dialog for adding GRASS commands to model.


๐Ÿฆ‹ Managing model parameters

Every module you use can be parameterized in the model. That means when you run the model, a dialog launches with the input options for it โ€” chef's kiss. In this example, the input layers (zipcodes_wake vector map and elev_state_500m raster map) are parameterized. Here's the cute little visual cue: parameterized elements show a diagram border that's slightly thicker than the unparameterized ones. Vibe check passed. ๐Ÿ‘‘

Figure: Model parameter settings.

The final model, the list of all model items, and the Script editor window with the Save and Run option are all shown in the figures below.

Figure: A model to perform average statistics for zipcode zones.

Figure: Items with Script editor window.

For convenience, this model for the Graphical Modeler is also available for download here. ๐Ÿซถ

The model runs when you click the Run button. Once all inputs are set, the results can be displayed as shown in the next Figure:

Figure: Average elevation for ZIP codes using North Carolina sample dataset as an automatic calculation performed by Graphical Modeler.


๐Ÿ’œ Managing model properties

So if you wanna run the model again with the same data or the same names, you have to use the --overwrite option. That's the one that makes maps with identical names get overwritten. Instead of setting it for every module separately (exhausting), it's way handier to change the Model Property settings globally. And this dialog also has metadata settings where you can specify the model name, model description, and author(s) of the model. Main character documentation energy, honestly. ๐Ÿ“

Figure: Model properties.


๐ŸŒˆ Defining variables

Another trick that's lowkey genius: you can set variables. Their content can be used as a substitute for other items. A variable's value can be stuff like raster or vector data, an integer, a float, a string value โ€” or they may constitute some region, mapset, file or direction data type. So basically you don't have to set any parameters for input data at all. The dialog with variable settings pops up automatically after the model is run. So instead of model parameters (e.g. r.import a v.import, see the Figure Run model dialog above) you get Variables. ๐Ÿ’ซ

Figure: Model with variable inputs.

The key point โ€” and I need you to hear me on this โ€” is enclosing the substituting variable in %{...} and setting the value in the Variables dialog. Example: say you've got a model variable raster that points to an input file path, and you need its value used as one of the inputs for a particular model. You'd specify it in the Variables dialog with its respective name (raster), data type, default value and description. Then you set it in the module dialog as input called %{raster}. Boom, done, that's it. โœจ

Figure: Example of raster file variable settings.

Figure: Example of raster file variable usage.


๐ŸŒธ Saving the model file

Finally, the model settings can be stored as a GRASS Model file with the *.gxm extension. The advantage? It can be shared as a reusable workflow that may be run by other users with different data. Reusable workflows are the moment, periodt. ๐Ÿ’…

For example, this model can later be used to calculate the average precipitation for every administrative region in Slovakia using the precip raster data from the Slovakia precipitation dataset and administration boundaries of Slovakia from Slovak Geoportal (only with a few clicks). Like, a few clicks. Not me being jealous of future-you. ๐Ÿ™ˆ


๐Ÿงš Handling intermediate data

Sometimes there's data in a model that didn't exist before the process and honestly isn't worth maintaining after the process executes. Those can be described as being Intermediate โ€” just single-click with the right mouse button, see the figure below. All such data should be deleted following model completion. And how do you spot them in the diagram? The boundary of an intermediate component is a dotted line. Cute, right? ๐ŸŽ€

Figure: Usage and definition of intermediate data in model.


๐Ÿ Using the Script editor

Using the Script editor in the Graphical Modeler, you can add Python code and then run it with the Run button, or just save it as a Python script *.py. The result is shown in the Figure below:

Figure: Script editor in the wxGUI Graphical Modeler.

Now, the second option in the Script type combobox exports a PyWPS script instead of a basic Python one. A PyWPS process based on the model gets generated then. Heads up though: for the PyWPS script the Run button is disabled, because users are expected to include this script in their web processing service and not to run it on itself. Don't fight it, bestie, it's just how it works. โœ‹

Figure: Script editor in the wxGUI Graphical Modeler - set to PyWPS.

The third option in the Script type combobox exports an actinia process chain (that's for a non-parameterized model) or an actinia template (that's for a parameterized model). An actinia JSON based on the model gets generated then โ€” and just like with the PyWPS script, the Run button is disabled, because users are expected to include this JSON in their web processing service and not to run it on itself.

Figure: Script editor in the wxGUI Graphical Modeler - set to actinia.

By default the GRASS script package API is used (grass.script.core.run_command()). This can be changed in the settings. Alternatively, the PyGRASS API is also supported (grass.pygrass.modules.Module). Options on options. ๐Ÿ”ฅ


๐Ÿ” Defining loops

In the example below, the MODIS MOD13Q1 (NDVI) satellite data products are used in a loop. The original data are stored as coded integer values that need to be multiplied by the value 0.0001 to represent real ndvi values. Also, GRASS provides a predefined color table called ndvi to represent ndvi data. In this case it's not necessary to work with every image separately โ€” thank god, honestly. ๐Ÿ˜ฎโ€๐Ÿ’จ

The Graphical Modeler is an appropriate tool to process data in an effective way using loop and variables (%{map} for a particular MODIS image in mapset and %{ndvi} for original data name suffix). After the loop component is added to the model, it's necessary to define a series of maps with the required settings of map type, mapset, etc.

Figure: MODIS data representation in GRASS after Graphical Modeler usage.

When the model is supplemented by all of modules, those modules should be ticked in the boxes of the loop dialog. The final model and its results are shown below. ๐Ÿฆ‹

Figure: Model with loop.

Figure: MODIS data representation in GRASS after Graphical Modeler usage.

The steps to enter in the command console of the Graphical Modeler would be as follows:

# note that the white space usage differs from the standard command line usage
# rename original image with preselected suffix
g.rename raster = %{map},%{map}.%{ndvi}
# convert integer values
r.mapcalc expression = %{map} = %{map}.%{ndvi} * 0.0001
# set color table appropriate for nvdi data
r.colors = map = %{map} color = ndvi

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

  • wxGUI, wxGUI components

See also selected user models available from GRASS Addons repository.

See also the wiki page (especially various video tutorials). ๐Ÿ“บ


๐Ÿ’– AUTHORS ๐Ÿ’–

  • Martin Landa, GeoForAll Lab, Czech Technical University in Prague, Czech Republic
  • PyWPS support by Ondrej Pesek, GeoForAll Lab, Czech Technical University in Prague, Czech Republic
  • Various manual improvements by Ludmila Furkevicova, Slovak University of Technology in Bratislava, Slovak Republic

โญ SOURCE CODE โญ

Available at: wxGUI Graphical Modeler source code (history)

Accessed: Tuesday Sep 08 11:56:22 2026

Main index | GUI index | Topics index | Keywords index | Graphical index | Full index


ยฉ 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual

That's the whole page, bestie โ€” and yes, it's GRASS 8.5.0, wxGUI.gmodeler(1grass), and you have officially read the entire thing. Go build a model and ate, fr fr. ๐Ÿ’…๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from