Lab 5 - Landscape Metric Creation



 In previous labs we have looked at occurrence data for a rare cactus in Utah. Using the same occurrence data and study area, we will begin the process of creating variables that may help describe where and why these cactus are occurring in the landscape. I have already place the base data into your network directories (\\wygiscdev\AdvSpatial\userName\LandscapeMetrics), but in case you want the data for later use you can download this zip file:



R and GRASS Method --


Download the functions to calculate metrics from R using GRASS 6.4.3: GeomorphometricsFunctions.R

Download the R script for using the Geomorphometric Functions: R_GRASS.R



End R and GRASS Method 







Open ArcGIS and load the three data layers: DEM_30m.img, NHD_Streams.shp, and ParietteCactus.shp. Let's make sure that the Data Frame has the correct projection, so:

right-click in the Data Frame → Data Frame Properties → Coordinate System tab

NAD83 Zone 12 should be listed. If not, make the necessary change to this projection.

Next we want to make sure relative paths are being stored, not explicit paths:

On the menu select File → Map Document Properties → Check the Store Relative pathnames box

Now Save your map document (*.mxd) to your directory.

Since we are working with raster data, we will want to ensure that we do not have 'raster creep' occur as we derive different metrics. To avoid potential errors and 'creep', we need to set our workspace environment:

in the menu select Geoprocessing → Environment Settings → Processing Extent →
Set Extent = DEM_30m.img
Snap Raster = DEM_30m.img
Click OK 

By specifying these settings, each newly created raster will have the 'origin' set to be the exact same coordinates as the DEM and the raster results will have the exact same 'extent' as the DEM. Thus, all of our data will be spatially matched up between all of the datasets.

Next we need to load the Geomorphometry and Gradient Metrics Toolbox. Go to:!arcgis-gradient-metrics-toolbox/crro and download the zip file to your directory. Extract all files. To make this toolbox available for use inside of ArcGIS:

Open/Expand ArcToolbox → Right click on ArcToolbox (the top toolbox) → Add Toolbox →
Navigate to the directory where you unzipped the Geomorphometry file and select 
Geomorphometry and Gradient Metrics (version a1.0).tbx

 You should now see the new toolbox in ArcToolbox. If you expand the toolbox you should see four sub-toolboxes labeled Statistics, Surface Texture/Configuration, Temperature and Moisture, and Utilities. We will use some of these Python Scripts to create metrics.


The first metric that we wish to create is the distance to streams. We feel that the distance to a 'major' stream is important in the maintenance of reliable sources of moisture, yet not necessarily overly moist areas. To see if there is a response, I have developed a stream data layer comprised of Strahler 3rd order or larger streams digitized at the 1:24K scale (the high-resolution NHD). Let's use the Euclidean distance tool to create a continuous surface of distance to streams:

ArcToolbox → Spatial Analyst Tools → Distance → Euclidean Distance →
 Input = NHD_Streams (best to obtain full path, not the alias, so use the Folder button)
Out Raster = StreamDist.img (don't forget the file extension!)
Output cell size = 30 (30x30 meter cell) 

You should see a rainbow-raster in which each cell represents the distance to the nearest stream.

ONE VERY IMPORTANT TASK: We want to track what steps we have done so that we can repeat the process if necessary. The easiest method I have found is to copy the Python Snippet:

On the menu select Geoprocessing → Results → Current Session → 
Righ-click on Euclidean Distance → Copy as Python Snippet 
Now paste the snippet into a textfile or Word document

By keeping this type of 'log-file' we can easily repeat our analysis or modify it to perform the work in a loop within Python for batch processing. This is a BIG time saver and will probably help you write your methods for a manuscript.


A DEM of your study area is probably one of the most important datasets that you can obtain, especially when trying to model potential habitat for rare plants (NOTE: for brevity of the lab, we are using a 30m DEM so that processing is faster. Finer resolution, when possible, will be ideal). We are going to use a couple of tools to describe the surface of the landscape because we have an intuitive feeling that the 'lay of the land' is influencing the locations where this cacuts is successfully surviving and reproducing. One potentially important factor may be if the cactus prefers concave or convex portions of the landscape.

ArcToolbox → Geomorphometry and Gradient Metrics → Surface Texture → Curvature
 Raster = DEM_30m.img
Neighborhood = 3 x 3
Output = Curve3cell.img 
Click OK
Copy the Python Snippet

 Notice that we had the option of setting the neigborhood for the moving window analysis. Sometimes, we may not know the 'scale' at which the target organism is responding. Thus, it is a good idea to calculate the same metric at more than one scale and test which scale is seeing the best response. So, run the Curvature tool again, only this time use a 7 x 7 cell window.

Our next hypothesis is that these plants may prefer steeper slopes. The metric we will use to test this hypothesis is the Surface Relief Ratio:

ArcToolbox → Geomorphometry and Gradient Metrics → Surface Texture → Surface Relief Ratio
 Raster = DEM_30m.img
Neighborhood = 3 x 3
Output = SRR3cell.img 
Click OK
Copy the Python Snippet

Run the SRR tool again, only this time use a 7 x 7 cell window.

For today's exercise, the final metric will represent the amount of potential solar irradiance reach each location on the landscape's surface. The metric of choice will be the Heat Load Index (HLI):

ArcToolbox → Geomorphometry and Gradient Metrics → Temperature and Moisture → Heat Load Index
 Raster = DEM_30m.img
Central Latitude = 40
Output = HLI.img 
Click OK
Copy the Python Snippet

Because this metric is a 'cell-specific' calculation, you could choose to perform a Focal Mean on the resulting raster using different window sizes to obtain a mean HLI so that you can 'smooth' the cell values given the area around the cell being measured. For today, we will skip this step.






Using the provided DEM (see above), please complete the calculation of the following Geomorphometrics:

  • Compound Topographic Index (3-cell)
  • Slope Cosine (3-cell)
  • Slope Sin (3-cell)
  • Topographic Radiation Aspect Index (3-cell)
  • Surface/Area Ratio (3-cell)
  • Dissection (3, 11, 33 cell)
  • Surface Relief Ratio (3, 11, 33 cell)
  • Slope Position (3, 11, 33 cell)
  • Topographic Roughness Index (3, 11, 33 cell)
  • Profile Curvature (3, 11, 33 cell)
  • Distance to Streams (in meters)

The results of these raster analyses need to be completed and in the 'LandscapeMetrics\Dervived' folder within your \\wygiscdev directory. You can choose to use either R/GRASS or ArcGIS. You must make sure that all of your derived rasters meet the 4 criteria of raster analyses. This task is DUE February 18, 2014!!


A very important part of creating species distribution models is having an efficient manner in which you can attribute each of your sample locations (and yes also your pseudo-absence data). For simplicity's sake, today we will just use some R code to attribute our ParietteCactus points. Ideally, we would have a point dataset comprised of all of our points that we may use in fitting a model. Download and open ExtractRasterValueToPoints.r . In this file we will use a for:loop and the raster package to create a list of rasters (our derived list of metrics) and create a raster stack. Using the raster stack, we will extract the values of all of the rasters within the stack for each observation point, then write the results back out to a shapefile for us to view within ArcGIS. After this step is complete, we have the beginnings of a matrix that we can use to fit a Logistic Regression model(s). Hooray for us!!