Skip to content

Analyzing DEM in QGIS

SBakar02 edited this page Jul 8, 2021 · 6 revisions

Data Downloads

Download DEMs here: https://earthexplorer.usgs.gov/ Download in GeoTIFF format, which contains pixel values and geographic location.
Make sure you have QGIS version 3.16.1 with GRASS 7.8.4. Download here: https://qgis.org/en/site/forusers/download.html The OSGeo4W Network Installer installs the latest long-term release and additional packages (like GRASS).

Create Topographic Map

Method

  1. Open DEM files in QGIS and save as new project.
  2. Merge DEMS (if necessary): Select raster > miscellaneous > merge. Select the desired DEMs as the input layers, save as new file.
  3. Clip the DEM (if needed) to desired area of interest: Select raster > extraction > clip raster by extent. Choose the merged DEM as the input layer. Click the three dots on the right hand side and select "draw on canvas". Use the tool to highlight your area of interest. Save as new file and run.
  4. Check the coordinate reference system (CRS) for your clipped DEM by right clicking on the layer and selecting properties. Under information, check the CRS and the unit. You want to work with a CRS with meters as the unit.
  5. Re-project the merged DEM to desired CRS (if necessary based on step 3): Select raster > projections > warp (reproject). Choose the merged DEM as the input layer and then select a target CRS by clicking the button next to the dropdown box. A pop up window will appear. Search for WGS 84/ UTM grid system and then select either northern or southern hemisphere (whichever applies to your area of interest). Save as new file and run.
  6. Visualize the terrain using hillshade: Select raster > analysis > hillshade. Choose the reprojected DEM as the input layer, save as new file, and run.
  7. Extract contour lines: Select raster > extract > contour. Choose the hillshade DEM and run.

Identify Watersheds

Method

  1. Using the search bar in the bottom left corner, find the GRASS tool r.fill.dir (https://grass.osgeo.org/grass76/manuals/r.fill.dir.html). Choose the merged, clipped, and reprojected DEM from step 4 above as your elevation layer. Leave the output direction format as grass. Save the depressionless DEM as new file (named DEM_Filled). Uncheck the boxes for flow direction and problem areas. Run.
  2. Use the search bar again to find the GRASS tool r.watershed (https://grass.osgeo.org/grass78/manuals/r.watershed.html). Choose the filled DEM as the elevation layer. Set the minimum size of the exterior watershed basin as the maximum pixel size of the filled DEM; you can find this value by right clicking the DEM_Filled layer and selecting properties. The maximum pixel size is found on the information tab. Check the box for enable single flow direction. Save the "number of cells that drain through each cell" as a new file called "accumulation". Save the "drainage direction" as a new filed called "flowdirection". Uncheck the remaining file boxes. Run.
  3. Open raster calculator: Raster > Raster Calculator. You want the flow direction values to all be positive. You can double click on your file name (in this step, your flow direction file) in the raster bands box to have it appear in the raster calculator expression. Type into the raster calculator expression box: "flowdirection@1 < 0" -1 flowdirection@1 + "flowdirection@1 >= 0" * flowdirection@1". Name output layer "flowdirectionabs" as this layer is now the absolute value of the flow direction. Use the three dots on the right side to choose where to save it. Leave the file in geoTIFF format. Select OK.
  4. Right click on flowdirectionabs in the layers tab and select properties. Go to symbology. Under band rendering, select paletted/unique color values. The band will be "band 1(Gray)". Click the dropdown arrow next to color ramp and select spectral. Right click the color ramp anywhere and select edit color ramp. Choose the same color for color 1 and color 2, then click OK. Select classify. You should see 8 values (1-8). Rename these in the following order: 1) North 2) North East 3) East 4) South East 5) South 6) South West 7) West 8) North West. Select apply and then OK.
  5. Determine a threshold in the accumulation layer to categorize a channel as a river. Use the information tool to hover over different areas on the accumulation layer and observe the accumulation values. Open raster calculator and type into the expression box: "(accumulation@1 >= insert threshold value) *accumulation1. Save this as a new geoTIFF file called channels.
  6. Use the search bar to find the GRASS tool r.stream.extract (https://grass.osgeo.org/grass78/manuals/r.stream.extract.html). Select DEM_Filled as your input map layer. The minimum flow accumulation for streams is the threshold you determined in step 5. Set the v.out.ogr output type as line. Save the unique stream ids (rast) as a new file called streams. Uncheck the remaining file boxes and run. Streams and Channels files should resemble each other.
  7. Use the search bar to find the GRASS tool r.water.outlet (https://grass.osgeo.org/grass79/manuals/r.water.outlet.html). Select the flowdirectionabs file as the input raster map. To select the outlet point, click the button with the three dots next to "coordinates of outlet point" and choose your outlet point with the tool that pops up. Choosing the outlet point can be tricky. Zoom into the area so that you can clearly see the stream and channel. Make sure you select a point that is in the water. Save as new file called Basin. Run.
  8. Use the search bar to find the GRASS tool r.to.vect (https://grass.osgeo.org/grass78/manuals/r.to.vect.html). Select the basin file created in step 7 as the input raster later. Set v.out.ogr output type as area. Save as new file (basin_vector) and run.

Compare to Published Watersheds

kmz file.

Clone this wiki locally