Posted on October 12th, 2012

Working In GDAL (WIG) – Creating a Terrain Roughness Index Map

In this monthly series, I turn my attention to one of the most powerful software packages for raster processing available – the Geospatial Data Abstraction Library (GDAL) – and as an added bonus, it’s free! Each month, I focus on a different utility offered in GDAL, walking the reader through its applications and offering up a series of tips and illustrations so that you can emulate this process in your office and/or home. In this edition of WIG, I show our readers how to use GDAL to create a terrain roughness index (TRI) map from a raster digital elevation model (DEM).

About GDAL

GDAL is an open source software application that was launched in 1998 and has been updated multiple times since. While the current version of GDAL (i.e. version 1.9) can be downloaded from multiple locations, I find this site to be the most up-to-date and easy to navigate. I suggest downloading the stable version of the MSVC2010 build for either 32-bit or 64-bit PCs depending on which you have access to. You can also download GDAL as part of an easier to install program, FW Tools, but the version of GDAL included with this installer is usually not the most recent.

GDAL contains a wide array of utilities to help you process raster files. I find that GDAL is more stable and runs quicker than ArcGIS, ENVI and PCI for data production – although the toolkit is more limited than in these applications. GDAL does not rate high for user-friendly functionality as it is command line driven (i.e. words and text, not graphics and mouse clicks); and this is the inspiration for creating the WIG series.

What is the Terrain Roughness Index?

Of all the GDAL commands I have discussed in the past editions of WIG, the TRI is by far the straightest forward to understand the mathematics and principles behind it. A TRI shows you how rough an area is as measured by changes in elevation from a central point to those that surround it. This roughness value is calculated using matrix math whereby the elevation of central point in a DEM is compared to the 8 neighboring pixels; the absolute value of each elevation difference is then summed and divided by 8 (i.e. an average is determined). Since TRI employs an absolute value in the average calculation, TRI is never less than 0. An area with a 0 value for TRI shows that the central point and its 8 neighbors have the exact same elevation or it is completely flat. As the TRI value grows, a landscape becomes more rough or undulating.

It should be noted that the range of TRI values is tied to the resolution of your input DEM. In that an elevation model with larger resolution can show more change from pixel to pixel as more ground is covered in a 10-meter DEM versus a 1-meter DEM, for example. As such, TRI should be thought of as a relative index to compare roughness within the same DEM as opposed to an absolute index to compare roughness across several DEMs with varying resolutions.

Creating a Terrain Roughness Index

In order to create a TRI map from a DEM, I employed the GDALDEM functions – you can find out more about them here. Here are the steps I took to calculate a hillshade:

  1. I moved my DEM file, a digital terrain model (DTM) produced by DigitalGlobe with 2-meter resolution over Gadara, India, to a folder called, ‘Test,’ located the root of my C: Drive
    1. I chose a simple folder name and file location (i.e. C:test) for the data to make things easier when working with the command line interface of GDAL
  2. I also changed the name of the DTM file to ‘DTM.tif’ to make things easier when working with GDAL
  3. After starting up GDAL, I used the command: cdtest
    1. This command points GDAL to the folder I created with the DTM
  4. If you would like to get a list of the files in the folder you are working in, use this command: dir
  5. To calculate TRI, I used the following command: gdaldem TRI DTM.tif TRI.tif
    1. In this command, the words ‘gdaldem TRI’ define the utility that GDAL uses to process the data
    2. ‘DTM.tif’ is the full name of the input (original) DEM file
    3. ‘TRI.tif’ is the name of the text-based file that will define my output color schema; creating this file is by far the most challenging part of the color relief command, and as such, is the focus of the remainder of the piece below
  6. There is no extra functionality commands that can be added to TRI in GDAL
    1. However you can change the file extension of the output file from TIFF (.tif) to any raster format that GDAL supports

Tips for Interpreting and Working with TRI Maps in ArcGIS

Similar to the other elevation-derived datasets we have created with GDAL, when you move over to ArcGIS to work with TRI data, creating a symbology schema is not as straight forward as we might like. One of the biggest challenges of viewing this data is that GDAL calculates TRI values at the edges of your elevation model even if that only contains black fill (or no data values). In order to overcome this, we need to get a sense of the maximum and minimum values for TRI.

small_classification

To determine the minimum is easy, that is 0, as by definition you will never get negative TRI values. To determine the maximum values, you will want to follow the same steps put forth in last month’s WIG as related to building and viewing histogram values accessed under the menu chain, Properties -> Symbology -> Classified. When you open these histograms, you will likely see a wide range of values for TRI; the ‘true’ values will be clustered close to the 0 bar on its right side (you can see an example of what to look for in the screengrabs below). Once you zoom in on these values, you can move the right slider bar on the histogram graph to find the maximum value. You will know you found the maximum value when the number elements on the bottom right of the graph screen stop moving. I found a range of values from 0 to 1.749 for TRI.

When I created symbology for my TRI map, I wanted four color classes that ranged from green (flat areas) to red (steepest areas) in order to make the information displayed in ArcGIS more intuitive. To do this, right click on your layer, go to Properties  Symbology  Classified. I chose four classes with a red to green color ramp. Now you need to ignore the TRI values that are found in your black fill areas. To do this, click on the Classify… button and then Exclusions, I used a range of 1.75-21000. This causes your black fill borders to have the same color as the lowest TRI class you create, so be wary of this when you interpret the map you have created.

TRI as a Link Between Human, Animal and Physical Geography

As a geographer, I cannot help but have interest in the link between human/animal and physical geography; and TRI is an instance where geospatial information shows a strong link between the two. For instance, many scientists have established that rough lands (i.e. hills and mountains) will lower regional incomes as it is more expensive to build, farm, grow, etc. on hills and mountains than it is on flat coastal plains. In Africa, Nunn and Puga postulate that while rough lands had a direct negative impact on income growth, they suggest that it had a net overall positive impact on development by protecting many of the internal inhabitants of the continent from the Slave Trade that lasted from the 1400s to ~1900 (see Nunn and Puga, NBER Working Paper 14918, April 2009). Burchfield et al. theorize that rolling hills encourage scattered human development in areas where things are more flat; while areas with mountain ranges at the fringes encourage compact development of available flat areas (see Burchfield et al., Causes of Sprawl, Quarterly Journal of Economics, Volume 121, Issue 2). In animals, TRI has been linked to population density as it can influence the quality of the local habitat (see Utah Cougar Management Plan, V. 1, Jan 27, 1999).

So when I created my own TRI map over a rural area in India, I had to satisfy my curiosity to see if the TRI map bore out similar linkages. And the answer to that appears to be a resounding yes. In the animations that follow, you will see that human development is located in flatter areas with trees occupying the steepest slopes on their own. Ah, the joys and wonders of geography!


base_to_TRI_flat

base_to_TRI_hills


Click the images above to see animations of the TRI map I created above overlain on high resolution satellite imagery that can be found in Esri’s base layers. The first animation shows a flatter area while the second shows an area with much greater relief. It should be noted that human development will often create flatter areas on the lands they disturb. (DTM Source: DigitalGlobe; Imagery Source: Esri)

Brock Adam McCarty

Map Wizard

(720) 470-7988

Brock@apollomapping.com

This entry was posted in The Geospatial Times and tagged , by Apollo Mapping. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

    The Geospatial Times Archive