Accessing and Visualizing Digital Elevation Models with Python | by Parvathy Krishnan


Digital Elevation Models (DEMs) represent a 3D surface model of the terrain. It represents a continuous topographic elevation surface through a series of cells where each cell represents the elevation (Z) of a feature at its location (X and Y). Digital Elevation Models only contain information about the elevation of geological features, such as valleys, mountains, and landslides, and do not include any elevation data concerning features such as vegetation or buildings.

Accurate high-resolution DEM data is important for hazard mapping because it provides a detailed representation of the terrain which is essential for assessing potential risks posed by natural hazards. This data can better inform predictive models of how climate change will affect various land surfaces, by allowing scientists to measure the effects of changing temperature, precipitation, and other climate-related factors on land surfaces of different elevations. DEM data can also be used to identify areas that are at risk of flooding, landslides, and other extreme weather events, which can help inform policy decisions about how to mitigate the impacts of climate change. Additionally, DEM data helps to create detailed maps which can be used to create evacuation plans, alert systems, and other risk-management strategies.

The United States Geological Survey (USGS) EarthExplorer is one of the most popular sources for global Digital Elevation Model (DEM) datasets. The USGS offers datasets with resolutions ranging from 10 meters to 1 arc-second, with updates occurring every 5 to 10 years. Other sources for global DEM datasets include the Copernicus Land Monitoring Service, the International Centre for Tropical Agriculture, and the Global Land Cover Facility.

This blog summarises how to download, and visualise openly available global Digital Elevation Models for any geographic area of interest using Python

To begin, we will download the shapefile of our chosen region of interest from the Humanitarian Data Exchange (HDX). We will then use the elevation package in Python, which provides an easy download, cache, and access to the global datasets SRTM 30m Global 1 arc second V003 elaborated by NASA and NGA hosted on Amazon S3 and SRTM 90m Digital Elevation Database v4.1 elaborated by CGIAR-CSI.

This package will allow us to download the DEM for a selected geographic boundary to the local system. We can then import this DEM into Python using a library such as GDAL or rasterio. We will then explore and visualize the DEM using matplotlib and calculate derivatives such as slope, and elevation contours.

Extracting the polygon for any administrative region of a country from OCHA through HDX

OCHA Field Information Services Section (FISS) is part of the UN Office for the Coordination of Humanitarian Affairs based in Geneva, Switzerland. The organization makes available Common Operational Datasets which are the authoritative reference datasets to support operations and decision-making in the initial response to a humanitarian emergency. One such dataset is the subnational administrative boundaries of countries which is made available through the Humanitarian Data Exchange Platform (HDX) under a Creative Commons Attribution for Intergovernmental Organisations license.

The code below visualizes the administrative boundaries for Armenia (used as an example for this tutorial) downloaded from HDX using folium.

Country’s Administrative Boundaries extracted from GADM through GADMDownloader (Image by Authors)

To download the DEM, let us choose one of the provinces Gegharkunik.

Extracted polygon for the selected ADM boundary (Image by Authors)

Downloading DEM to a local path using the elevation package

The package allows the download of two datasets that can be given specified by the attribute product (SRTM1 or SRTM3).

  • SRTM1 (30m resolution) — NASA JPL (2013). NASA Shuttle Radar Topography Mission Global 1 arc second number [Data set]. NASA EOSDIS Land Processes DAAC. Accessed 2023–03–06 from https://doi.org/10.5067/MEaSUREs/SRTM/SRTMGL1N.003
  • SRTM3 (90m resolution)— Jarvis A., H.I. Reuter, A. Nelson, E. Guevara, 2008, Hole-filled seamless SRTM data V4, International Centre for Tropical Agriculture (CIAT), available from http://srtm.csi.cgiar.org.

In this tutorial, we are using SRTM1 data, the data citation and policies concerning the use of this data are available at the Land Processes Distributed Active Archive Center.

Please note that we need to provide an absolute file path for downloading the DEM as a TIF file; failure to do so will result in an error.

DEM Extracted using the elevation package in Python and clipped for the polygon of interest (Image by Authors)

Visualizing DEM terrain attributes with matplotlib and RichDEM

In this section, we will visualize some of the terrain attributes of Digital Elevation Models using matplotlib and richdem.

Elevation contours in DEM are lines that connect points of equal elevation. These contours help to show the three-dimensional shape of the terrain and can be used to measure distances, calculate watersheds, and determine slopes. matplotlib has options to plot the elevation contours either as lines or filled regions as demonstrated in the code below.

Visualizing Elevation Contours with matplotlib (Image by Authors)

Histogram of a DEM is represented as a bar graph, with each bar representing the frequency of a particular elevation value. The height of each bar corresponds to the number of times that particular elevation value occurs within the data set. A DEM histogram can be used to identify elevation extremes, as well as to detect elevation outliers or to determine the overall elevation range within the data set.

Distribution of DEM Elevation Values (Image by Authors)

Slope is a terrain attribute, or measurement, that describes the rate of change in elevation in a given area. It is the measure of the steepness or inclination of a surface and is typically represented as a percentage or an angle.

The slope of a DEM is typically expressed in degrees, ranging from 0° (flat) to 90° (vertical). Armenia is generally a mountainous country, with most of its terrain featuring steep slopes. The country does have some flat or gently sloping areas, primarily in the valleys of the Aras and Araks rivers.

Terrain Attribute Slope in Degrees (Image by Authors)

When the slope is represented as a percentage, it is calculated as the ratio of the elevation (rise) over a given distance (run) and is called Slope Rise-Run. A slope rise-run of 14% means that for every 100 units horizontally, the slope rises by 14 units vertically. For example, the highest slope rise-run is located in the Caucasus Mountains in Armenia, near the border with Georgia and Azerbaijan. The Caucasus Mountains in Armenia are a range of mountains that form part of the Euro-Asian mountain system and are located in the south of the country. The average elevation of the mountain range is approximately 4,500 meters (14,764 feet). The average slope of the Caucasus Mountains in Armenia is 15%.

Terrain Attribute Slope Rise-Run in Percentage (Image by Authors)

Aspect in degrees is a numerical measure of the orientation of the slope of a given location on the surface of the earth. It is measured as an angle from 0 to 360 degrees, with 0° representing the north, 90° representing the east, 180° representing the south, and 270° representing the west.

Terrain Attribute Aspect in degrees (Image by Authors)

Visualizing and analyzing digital elevation models is important for many use cases around climate change, hazard risk mitigation, and infrastructure planning as it allows for the analysis of topographic features that are essential for understanding the dynamics of climate change, assessing the risk of natural hazards, and designing effective infrastructure projects. DEM data also form the basis for generating digital terrain models, which can be used to map areas vulnerable to flooding, landslides, and other extreme weather events. Furthermore, DEM data can be used to create detailed 3D models of landscapes and terrain that can be used to simulate potential infrastructure projects, such as roads and bridges, and to assess their environmental impact.

We hope you now have a better understanding of how to use Python to download, explore, and visualize the Digital Elevation Model (DEM) and its attributes. With this knowledge, you can use Python to create detailed maps of terrain and analyze the elevation of different areas. In addition, you can use Python to compare different DEMs and their attributes and gain insights into changes in terrain over time. With these tools, you will be able to explore and analyze the landscape in depth.



Source link

Leave a Comment