How can find the number of mountains that is crossed by a line between two points on a map?

I guess I might adapt the answer to Number of buildings between two points but I don't exactly know how.

  • could you include what software or programming language do you want to use? and if you want to use a script what you already have tried
    – LaughU
    Commented Jan 10, 2018 at 14:05
  • Do you also have a DEM raster for doing that?
    – xunilk
    Commented Jan 10, 2018 at 14:11
  • @LaughU I supposed, for link question, that software is QGIS.
    – xunilk
    Commented Jan 10, 2018 at 14:19
  • @LaughU Sorry I forgot to add, I use qgis. I'm a total newcomer so I haven't tried anything, but I thought I could modify the answer that I linked in my question somehow. Commented Jan 10, 2018 at 14:20
  • @xunilk Can I not use GMTED2010 for that? Commented Jan 10, 2018 at 14:25

2 Answers 2



This is a methodology I once came across once to identify ridgelines. It might be a good start.

An option would be to try this.

  1. Take your surface (DEM) and multiply it by "-1". The purpose of doing this is to invert the elevations of the raster.
  2. Take this new surface and run it through the hydrological tools in GRASS / SAGA to generate a river vector file. I am unfamiliar with the QGIS / GRASS methodology to do this, but simplistically in ESRI software you calculate flow direction, flow accumulation and convert to river.
  3. This derived river file could be seen as the ridge-lines of your mountain range. Buffer it by 5m to make a polygon.

With the new polygon layer you can try the methodology provided in the link in your question.


You can use "Profile Tool" QGIS plugin. Install it as it is usual (Plugins -> Manage and Install Plugins).

Afterward, I tried plugin out with following layers (line shapefile and raster DEM):

enter image description here

With your DEM as active layer, click at plugin icon and add raster layer with "selection" in "Selected polyline". It looks as following image:

enter image description here

Afterward, select line layer as active and click in whatever point of Map Canvas to get some similar to following image:

enter image description here

Now, you can use your own criterion for selecting how many mountains you observe in generated profile.

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.