12.2. Lesson: Ferramentas GRASS

Nesta lição iremos apresentar uma seleção de ferramentas para voce ter uma idéia da capacidade do GRASS.

12.2.1. básico Follow Along: Create an aspect map

  1. Open the GRASS Tools tab

  2. Load the g_dem raster layer from the grass_mapset Mapset

  3. Look for the r.aspect module by searching for it in the Filter field of the Modules List tab

  4. Open the tool and set it up like this and click on the Run button:

    ../../../_images/grass_aspect.png
  5. When the process is finished click on View Output to load the resulting layer in the canvas:

../../../_images/grass_aspect_result.png

The g_aspect layer is stored within the grass_mapset Mapset so you can remove the layer from the canvas and reload it whenever you want.

12.2.2. básico Follow Along: Get basic statistic of raster layer

We want to know some basic statistics of the g_dem raster layer.

  1. Open the GRASS Tools tab

  2. Load the g_dem raster layer from the grass_mapset Mapset

  3. Look for the r.info module by searching for it in the Filter field of the Modules List tab

  4. Set up the tool like this and click on Run:

    ../../../_images/grass_raster_info.png
  5. Within the Output tab you will see some raster information printed, like the path of the file, the number of rows and columns and other useful information:

    ../../../_images/grass_raster_info_result.png

12.2.3. moderado Follow Along: The Reclass Tool

Reclassifying a raster layer is a very useful task. We just created the g_aspect layer from the g_dem one. The value range gets from 0 (North) passing through 90 (East), 180 (South), 270 (West) and finally to 360 (North again). We can reclassify the g_aspect layer to have just 4 categories following specific rules (North = 1, East = 2, South = 3 and West = 4).

Grass reclassify tool accepts a txt file with the defined rules. Writing the rules is very simple and the GRASS Manual contains very good description.

Dica

Each GRASS tool has its own Manual tab. Take the time to read the description of the tool you are using to don’t miss some useful parameters

  1. Load the g_aspect layer or, if you don’t have create it, go back to the Follow Along: Create an aspect map section.

  2. Look for the r.reclass module by searching for it in the Filter field of the Modules List tab

  3. Open the tool and set it up like the following picture. The file containing the rules is in the exercise_data/grass/ folder, named reclass_aspect.txt.

  4. Click on Run and wait until the process is finished:

    ../../../_images/grass_reclass.png
  5. Click on View Output to load the reclassified raster in the canvas

    The new layer is made up by just 4 values (1, 2, 3, and 4) and it is easier to manage and to process.

    ../../../_images/grass_reclass_result.png

Dica

Open the reclass_aspect.txt with a text editor to see the rules and to start becoming used to them. Moreover, take a deep look at the GRASS manual: a lot of different examples are pointed out.

12.2.4. moderado Try Yourself Reclassify with your rules

Try to reclassify the g_dem layer into 3 new categories:

  • de 0 a 1000, novo valor = 1

  • de 1000 a 1400, novo valor = 2

  • de 1400 ao valor raster máximo, novo valor = 3

12.2.5. moderado Follow Along: A Ferramenta Mapcalc

The Mapcalc tools is similar to the Raster Calculator of QGIS. You can perform mathematical operation on one or more raster layers and the final result will be a new layer with the calculated values.

The aim of the next exercise is to extract the values greater than 1000 from the g_dem raster layer.

  1. Look for the r.mapcalc module by searching for it in the Filter field of the Modules List tab.

  2. Iniciar a ferramenta.

    The Mapcalc dialog allows you to construct a sequence of analyses to be performed on a raster, or collection of rasters. You will use these tools to do so:

    ../../../_images/map_calc_tools.png

    Por ordem, são eles:

    • Add map: Add a raster file from your current GRASS mapset.

    • Add constant value: Add a constant value to be used in functions, 1000 in this case

    • Add operator or function: Add an operator or function to be connected to inputs and outputs, we will use the operator greater equals than

    • Add connection: Connect elements. Using this tool, click and drag from the red dot on one item to the red dot on another item. Dots that are correctly connected to a connector line will turn gray. If the line or dot is red, it is not properly connected!

    • Select item: Select an item and move selected items.

    • Delete selected item: Removes the selected item from the current mapcalc sheet, but not from the mapset (if it is an existing raster)

    • Open: Open an existing file with the operation defined

    • Save: Save all the operation in a file

    • Save as: Save all the operations as a new file on the disk.

  3. Usando essas ferramentas, construa o seguinte algoritmo:

    ../../../_images/grass_mapcalc.png
  4. Click on Run and then on View output to see the output displayed in your map:

    ../../../_images/grass_mapcalc_result.png

Isso mostra todas as áreas onde o terreno é superior a 1000 metros.

Dica

You can also save the formula you have created and load it in another QGIS project by clicking on the last button on the GRASS Mapcalc toolbar.

12.2.6. In Conclusion

Nesta lição, nós mostramos apenas algumas das muitas ferramentas oferecidas pelo GRASS. Para explorar as capacidades do GRASS para si mesmo, abrir o diálogo Ferramentas GRASS e role a Lista de Módulos. Ou para uma abordagem mais estruturada, olhar sob a guia Árvore de módulos, que organiza ferramentas por tipo.