Creating an elevation profile

Creating an elevation profile is very helpful when trying to visualize a 3D terrain cross-section or simply to see the elevation gain of a bike tour. In this example, we will define our own LineString geometry and extract the elevation values from the DEMs that are located every 20 m along our line. The analysis will generate a new CSV file that we can open in Libre Office Calc or Microsoft Excel to visualize the new data as a line chart.

The 2D view of our line plotted on top of the elevation model as seen inside QGIS looks like this:

Creating an elevation profile

Getting ready

This recipe calls for GDAL and Shapely. Make sure that you have them installed ...

Get Python Geospatial Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.