Introduction to GRASS GIS with terrain analysis examples

From GRASS-Wiki
Jump to navigation Jump to search

GRASS Terrain Analysis

This exercise was initially created as a session in the Advanced GIS training for the U. S. Fish and Wildlife Service  (CSP7300)  June, 2015 by Doug Newcomb and updated September 2015 with input from Paul Lang.

Session Objectives:  At the conclusion of this session, you will be able to:

  • Open GRASS GIS and Create a Location from an existing file
  • Link external raster elevation data to the Location
  • Install r.geomorphon addon
  • Create geomorphon layer from dem layer
  • Export raster data layer from GRASS to GeoTiff

Material Created By:  Doug Newcomb (June 2015)

Revision: Doug Newcomb (March 2016)

Software:  GRASS 7.0

Directory Path: D:\CSP7300_Terrain

Imagery: pen_1m_elevation.tif,  island_mask.tif

Elevation data is commonly used in landscape analysis.  The geomorphon addon in GRASS GIS can analyse an elevation raster and classify the surface into common landforms. All data are located in D:\CSP7300_Terrain, unless otherwise noted.

Step 1:  Creating GRASS Location

The first thing to do when starting to work in GRASS is to create a Location.  GRASS Locations are single projection areas with a defined resolution and extent. The initial location can be easily created from an existing data set.

  • In Windows, Click on Start-->All Programs-->GRASS GIS 7.0--> GRASS GIS 7.0 GUI

Two windows will open, the GRASS startup window ( to select or create a workspace) and the GRASS command prompt.

Initial GRASS startup screen on Windows


  • Click on the New button between the Location and Mapset windows. This will bring up the menu to define a new Location.

Location Menu 1

The GIS Data Directory is where all of your GRASS Locations will reside. Creating a new directory with a unique name for GRASS data is recommended. This directory can be created anywhere that the user has write access. Project location is a subdirectory name for this particular project. Like with ArcGIS, it is best to aviod spaces in Directory names to avoid problems down the road. The data is from the Pensacola,FL and is in a UTM projection, so call it pensacola_utm

  • Enter the Data Directory and Project Location and click Next – this brings up the location creation method menu.

Defining location projection

  • Click on the radio button for Read projection and datum terms from a georeferenced file.
  • Click Next

This brings up the georeferenced file dialog. Georeferenced file selection dialog

  • Browse and select to the D:\CSP7300\GRASS_Terrain \imagery\pen_1m_elev.tif as the georeferenced file.
  • Click Next.

GRASS reads the projection and datum information from the elevation file and displays the projection data. End of Locationcreation dialog

  • Click Finish

The next message relates to setting a default path for GRASS startup.

In the following message, you have the option if importing the data set you used for georeferencing the workspace.

Import georeferenced file dialog

  • Click No

The location has been created. You are prompted to set the default region extents and resolution.

Set Extents Dialog

  • Click No

You are then prompted to create a new mapset.

Create new mapset dialog

  • Click Cancel

You have finished creating a Location with the default PERMANENT mapset. The nest time GRASS is started, you can either select an existing Location and Mapset, Create a new mapset within the Location, or Create a new Location.

  • Click on the PERMANENT Mapset
  • Click Start GRASS session

You will then see the Layer Manager Window, the Map Display Window for Display 1.

Step 2: Adding a data layer

We are now ready to add data to the Mapset. We can either import Raster and Vector data using the GDAL translation library, or we can link to existing external data sets read only to reduce data duplication. In this case, we will link to the 1m elevation data we used to create the Location using the r.external command.

  • In the Layer Manager window, click File-->Link external data-->Link external raster data.

Add data dialog

This brings up the r.external dialog.

r.exteranl dialog

  • Browse to D:\CSP7300\GRASS_Terrain \imagery\pen_1m_elev.tif
  • Click on the box for Extend region extents based on new dataset. Note that Add layers into layer tree is checked. For large data sets, leave this unchecked.
  • Click Link.

The Layer Manager window will switch to the Command console tab and display the results of the r.external command.

Result of r.external

The raster is also displayed in the Map Display window. The image is 945 million pixels. It takes much less time to link to it than import it.

Step 3: Setting up the region

The region in a GRASS mapset defines the extent and resolution of the results of any raster actions. To make sure that all of a raster layer is affected by a command, it is customary to set the region’s extent and resolution to match the raster layer. To set the region to match the elevation raster that we just linked to:

  • From the Layer Manager window drop down options, click the Settings-->Region-->Set region

Access the region settings

  • In the g.region menu, in the Set region to match raster map section, use the drop down to select pen_1m_elev@Permanent.
  • Click Run

Region settings dialog

When the command finishes, your will see output in the g.region window and in the layer manager window.

  • Click Close in the g.region window
  • Click Settings-->Region-->Display region

Terrain17.png

In the command console tab of the Layer Manager window, you see the current region definition: resolution, bounds, rows and columns.

Terrain18.png

However, we are not really interested in the entire area, just a small section of the Western island. Let’s zoom into the area of interest with the Zoom tool on the Display window. Zoom tool

  • Click on the Zoom tool at the top of the Display window.
  • Click and drag to form a box around the fat portion of the western island.

Your Display window should look like this:

Terrain20.png

Since we are only working with this area, we can change the region values so that processing is only done in this area. The easiest way to do this is to:

  • Click on the Various zoom options button on the Display window
  • Select Set computational region extent from display