QGIS GRASS Cookbook: Difference between revisions
mNo edit summary |
(+Further reading) |
||
Line 28: | Line 28: | ||
* In Select GRASS raster layer dialog which opens: (screenshot) | * In Select GRASS raster layer dialog which opens: (screenshot) | ||
* click on Browse button and in the standard file dialog select the director where you extracted Spearfish demo dataset. For example, if you extracted Spearfish package in directory C:\gdata\ (so that path to the dataset directory is C:\gdata\spearfish) select C:\gdata\ directory. The Location combobox will populate with existing locations. | * click on Browse button and in the standard file dialog select the director where you extracted Spearfish demo dataset. For example, if you extracted Spearfish package in directory C:\gdata\ (so that path to the dataset directory is C:\gdata\spearfish) select C:\gdata\ directory. The Location combobox will populate with existing locations. | ||
* In the Location combobox select your | * In the Location combobox select your spearfish location, in the Mapset combobox select PERMANENT and in the Map name combobox select elevation.10m: (screenshot) | ||
* Push OK button. QGIS will load and display the selected layer as shown on the snapshot: (screenshot) | * Push OK button. QGIS will load and display the selected layer as shown on the snapshot: (screenshot) | ||
* In GRASS Toolbox click on Add GRASS vector layer tool: (screenshot) | * In GRASS Toolbox click on Add GRASS vector layer tool: (screenshot) | ||
Line 55: | Line 55: | ||
# If the current region is inside current QGIS extent the current GRASS region will be drawn as red (by default) rectangle (screenshot) | # If the current region is inside current QGIS extent the current GRASS region will be drawn as red (by default) rectangle (screenshot) | ||
# Because raster analysis on large raster files can be time consuming it is often useful to set current region to a smaller area than that covered by the whole input raster. Click on '''Edit Current GRASS Region''' tool (screenshot) | # Because raster analysis on large raster files can be time consuming it is often useful to set current region to a smaller area than that covered by the whole input raster. Click on '''Edit Current GRASS Region''' tool (screenshot) | ||
# In the ''GRASS Region Settings'' which opens (screenshot) | # In the ''GRASS Region Settings'' which opens (screenshot) | ||
you can enter new valuse for region extent and resolution. Alternatively you can define a new region in QGIS canvas with mouse while the ''GRASS Region Settings'' dialog is open. (screenshot) | you can enter new valuse for region extent and resolution. Alternatively you can define a new region in QGIS canvas with mouse while the ''GRASS Region Settings'' dialog is open. (screenshot) | ||
# If you are content with new region settings click on '''OK''' button and the defined region will become current GRASS region for open mapset. From now on all the modules working with rasters will read/write data in current region with current resolution. Note also that physical resolution of output raster maps does not depend on input map but on resolution of current region. The new region displayed in QGIS map canvas: (screenshot) | # If you are content with new region settings click on '''OK''' button and the defined region will become current GRASS region for open mapset. From now on all the modules working with rasters will read/write data in current region with current resolution. Note also that physical resolution of output raster maps does not depend on input map but on resolution of current region. The new region displayed in QGIS map canvas: (screenshot) | ||
Line 64: | Line 64: | ||
# When the progress reaches 100% and message '''Successfully finished''' is printed in the text output you can add the output map to QGIS map canvas. As you see the map extent corresponds to the previously set GRASS region (screenshot) | # When the progress reaches 100% and message '''Successfully finished''' is printed in the text output you can add the output map to QGIS map canvas. As you see the map extent corresponds to the previously set GRASS region (screenshot) | ||
# Optional tip. You can change transparency of the new aspect map to enhance visualisation of the DEM (screenshot) | # Optional tip. You can change transparency of the new aspect map to enhance visualisation of the DEM (screenshot) | ||
=== Further reading ==== | |||
* [http://www.dur.ac.uk/resources/geography/conferences/3d_modeling/lidar_lab_notes_r_bennett.pdf Using QGIS and GRASS for Processing and Analysing Lidar Data] (Lab, 2010) | |||
* [http://blog.qgis.org/node/90 Screencast - Loading Data into GRASS with QGIS] (2007) |
Revision as of 04:04, 1 November 2010
GRASS Cookbook
The GRASS Cookbook (GCB) is a collection of recipes for typical GIS tasks which can be accomplished with GRASS plugin in QGIS. The recipes can be tried in any order but it is recommended to go through the Getting started section first. Each recipe can be reproduced with publicly available demo dataset. The cookbook presumes that the user has QGIS with GRASS plugin installed (and GRASS plugin enabled in QGIS) and that s/he knows QGIS basics.
All the recipes (except some in Getting started section) requires open existing mapset (you can learn that in the OpenMapset section how to open a mapset). If a recipe has input maps in header it is expected that the maps are displayed in QGIS (you can learn that in the DisplayMap section how to display a map). The requested input maps are described in form 'map@mapset' which is standard GRASS notation.
The information about effort (number of clicks and key strokes per each recipe) is only approximate.
Demo datasets
- Spearfish: ZIP (Windows), TAR (Linux/Mac)
Getting started
- Display Map (18 clicks)
- Create new Mapset (13 clicks, 5 keystrokes)
- Open existing Mapset (12 clicks)
- Using GRASS Toolbox (11 clicks, 6 key strokes)
Displaying GRASS Maps
- Objective: Display GRASS maps in QGIS
- Dataset: Spearfish
- Effort: 18 clicks
- By: Radim Blazek
- In GRASS Toolbox click on Add GRASS raster layer tool
- In Select GRASS raster layer dialog which opens: (screenshot)
- click on Browse button and in the standard file dialog select the director where you extracted Spearfish demo dataset. For example, if you extracted Spearfish package in directory C:\gdata\ (so that path to the dataset directory is C:\gdata\spearfish) select C:\gdata\ directory. The Location combobox will populate with existing locations.
- In the Location combobox select your spearfish location, in the Mapset combobox select PERMANENT and in the Map name combobox select elevation.10m: (screenshot)
- Push OK button. QGIS will load and display the selected layer as shown on the snapshot: (screenshot)
- In GRASS Toolbox click on Add GRASS vector layer tool: (screenshot)
- In the 'Select GRASS vector layer select in the Map name combobox map roads and in the Layer combobox select 1_line: (screenshot)
- Push OK button. QGIS will load and display the selected vectors layer over the previously loaded raster as shown on the snapshot: (screenshot)
Create new Mapset
...
Open existing Mapset
...
Using GRASS Toolbox
- Objective: To learn how to set GRASS region and how to run GRASS modules in QGIS
- Dataset: Spearfish
- Input maps: soils@PERMANENT (vector)
- Effort: 11 clicks, 6 key strokes
- By: Radim Blazek
As the first example we will use a module which generates aspect map from raster DEM (digital elevation model). Because all GRASS modules which read or write rasters always work in current region we will learn first how to visualize and modify current GRASS region.
- The GRASS region is a rectangle defining certain area. To visualize the current region in QGIS switch on Display current region tool in GRASS toolbox (screenshot)
- If the current region is inside current QGIS extent the current GRASS region will be drawn as red (by default) rectangle (screenshot)
- Because raster analysis on large raster files can be time consuming it is often useful to set current region to a smaller area than that covered by the whole input raster. Click on Edit Current GRASS Region tool (screenshot)
- In the GRASS Region Settings which opens (screenshot)
you can enter new valuse for region extent and resolution. Alternatively you can define a new region in QGIS canvas with mouse while the GRASS Region Settings dialog is open. (screenshot)
- If you are content with new region settings click on OK button and the defined region will become current GRASS region for open mapset. From now on all the modules working with rasters will read/write data in current region with current resolution. Note also that physical resolution of output raster maps does not depend on input map but on resolution of current region. The new region displayed in QGIS map canvas: (screenshot)
- Open GRASS tools clicking on Open GRASS Tools in GRASS Toolbox (screenshot)
- In the GRASS Tools window tab Modules click on tool Generate aspect map from DEM (screenshot)
- In the new tab which is opened for the selected tool select Elevation.10m as input and type aspect as name of output (screenshot)
- If you click on Run button the module will be started and module's interface will be switched to Output. In the output tab are printed messages from the running modules. You can follow the progress on the bar under the text output (screenshot)
- When the progress reaches 100% and message Successfully finished is printed in the text output you can add the output map to QGIS map canvas. As you see the map extent corresponds to the previously set GRASS region (screenshot)
- Optional tip. You can change transparency of the new aspect map to enhance visualisation of the DEM (screenshot)