Calculating elevation profile along line from a DEM?

The GRASS command r.profile performs this (documentation, source) and should provide a good basis for implementing a cross section, and is available under the GPL.


Maybe QGIS "Profile" plugin source code can be a start.

alt text


You can go much further by combining DEM and raster colors, using GRASS with R. See:

  • Raster profile along arbitrary line segments, or
  • http://www.portailsig.org/content/grass-gis-et-r-superposition-des-couleurs-d-un-raster-quelconque-sur-un-profil-topographique and,
  • with Python (Python: utilisation des couches vectorielles et matricielles dans une perspective géologique, sans logiciel SIG; in French, but the scripts are universal).

See some examples below:

With elevation colors (GRASS GIS and R):

enter image description here

With colors of a Geological Map (Python with GRASS raster):

enter image description here

And using the Python script in the Python console of QGIS:

enter image description here