Accessing and Visualizing Digital Elevation Models with Python

-

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 in regards to the elevation of geological features, reminiscent of valleys, mountains, and landslides, and don’t include any elevation data concerning features reminiscent of vegetation or buildings.

Accurate high-resolution DEM data is significant for hazard mapping since it provides an in depth representation of the terrain which is important for assessing potential risks posed by natural hazards. This data can higher inform predictive models of how climate change will affect various land surfaces, by allowing scientists to measure the consequences of adjusting temperature, precipitation, and other climate-related aspects on land surfaces of various elevations. DEM data will also be used to discover areas which are vulnerable to flooding, landslides, and other extreme weather events, which may also help inform policy decisions about tips on how to mitigate the impacts of climate change. Moreover, DEM data helps to create detailed maps which could be used to create evacuation plans, alert systems, and other risk-management strategies.

The US Geological Survey (USGS) EarthExplorer is one of the crucial popular sources for global Digital Elevation Model (DEM) datasets. The USGS offers datasets with resolutions starting 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 tips on how to download, and visualise openly available global Digital Elevation Models for any geographic area of interest using Python

To start, we are going to download the shapefile of our chosen region of interest from the Humanitarian Data Exchange (HDX). We’ll then use the elevation package in Python, which provides a straightforward download, cache, and access to the worldwide 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 specific geographic boundary to the local system. We are able to then import this DEM into Python using a library reminiscent of GDAL or rasterio. We’ll then explore and visualize the DEM using matplotlib and calculate derivatives reminiscent of slope, and elevation contours.

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

OCHA Field Information Services Section (FISS) is an element of the UN Office for the Coordination of Humanitarian Affairs based in Geneva, Switzerland. The organization makes available Common Operational Datasets that are the authoritative reference datasets to support operations and decision-making within the initial response to a humanitarian emergency. One such dataset is the subnational administrative boundaries of nations 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 executive boundaries for Armenia (used for instance for this tutorial) downloaded from HDX using folium.

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

To download the DEM, allow us to select one in every of the provinces Gegharkunik.

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

Downloading DEM to an area path using the elevation package

The package allows the download of two datasets that could 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.

On this tutorial, we’re using SRTM1 data, the information citation and policies in regards to the use of this data can be found on the Land Processes Distributed Energetic Archive Center.

Please note that we want to offer an absolute file path for downloading the DEM as a TIF file; failure to accomplish that will lead to 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

On this section, we are going to visualize a few 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 point out the three-dimensional shape of the terrain and could 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 within 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 selected elevation value. The peak of every bar corresponds to the variety of times that specific elevation value occurs throughout the data set. A DEM histogram could be used to discover elevation extremes, in addition to to detect elevation outliers or to find out the general elevation range throughout the data set.

Distribution of DEM Elevation Values (Image by Authors)

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

The slope of a DEM is usually expressed in degrees, starting from 0° (flat) to 90° (vertical). Armenia is usually a mountainous country, with most of its terrain featuring steep slopes. The country does have some flat or gently sloping areas, primarily within 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’s calculated because the ratio of the elevation (rise) over a given distance (run) and is named Slope Rise-Run. A slope rise-run of 14% signifies that for each 100 units horizontally, the slope rises by 14 units vertically. For instance, the very best slope rise-run is situated within the Caucasus Mountains in Armenia, near the border with Georgia and Azerbaijan. The Caucasus Mountains in Armenia are a variety of mountains that form a part of the Euro-Asian mountain system and are situated within the south of the country. The common elevation of the mountain range is roughly 4,500 meters (14,764 feet). The common 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’s 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 significant for a lot of use cases around climate change, hazard risk mitigation, and infrastructure planning because it allows for the evaluation of topographic features which are essential for understanding the dynamics of climate change, assessing the chance of natural hazards, and designing effective infrastructure projects. DEM data also form the idea for generating digital terrain models, which could be used to map areas vulnerable to flooding, landslides, and other extreme weather events. Moreover, DEM data could be used to create detailed 3D models of landscapes and terrain that could be used to simulate potential infrastructure projects, reminiscent of roads and bridges, and to evaluate their environmental impact.

We hope you now have a greater understanding of tips on how to use Python to download, explore, and visualize the Digital Elevation Model (DEM) and its attributes. With this data, you should use Python to create detailed maps of terrain and analyze the elevation of various areas. As well as, you should use Python to check different DEMs and their attributes and gain insights into changes in terrain over time. With these tools, you’ll have the opportunity to explore and analyze the landscape in depth.

ASK ANA

What are your thoughts on this topic?
Let us know in the comments below.

2 COMMENTS

5 1 vote
Article Rating
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

2
0
Would love your thoughts, please comment.x
()
x