16

Given a DEM (Digital Elevation Model) and a line (x1,y1) --> (x2,y2) (paired coordinates (x,y)), how can one calculate the elevation profile or cross-section projected on that line?

I am looking for an open source code that I can use in my project or pseudo-code that I can use as a guide.

4 Answers 4

14

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.

12

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

alt text

1
  • This would be nice thing to have built into QGIS. Maybe under the raster menu. Also have multiple lines the GRASS example would be cool.
    – Nathan W
    Commented Sep 28, 2011 at 0:34
5

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

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

4

Here screenshots for GRASS: alt text alt text

1
  • 1
    Are these pictures derived from the tool specified in scw's answer (r.profile), or are they from another tool (a GUI tool, for example)? Perhaps the answer could be improved if you specify the name of the tool, some reference for its documentation and where it can be accessed within the software. Commented Jul 16, 2016 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.