O'Reilly logo

Python Geospatial Analysis Cookbook by Michael Diener

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required