2

I'm trying to do terrain analysis in QGIS.

I have a vector layer with equally spaced points along a slope, and these points are somewhat parallel to the coastline of a fjord:

Hillshade of a fjord with evenly spaced points sub-parallel to the coastline

I'm interested in finding the shortest path between each of these points and sea level (elevation = 0). Ideally, this would generate a new polyline layer with a bunch of straight lines between the red points and the ocean. In other words, I'm hoping to generate lines with the steepest overall slope that begin at each of the red circles.

To be clear, I'm not trying to do flow routing—these lines can go up and over bumps in the topography so long as they minimize the as-the-crow-flies distance between the points and sea level.

Any thoughts on how to accomplish this? I've found plenty of points about finding the shortest path between two points or between a point and a line layer, but nothing quite like this. One thought I had was generating closely-spaced lines along the shoreline and finding lines between my two point layers, but that seems a bit of a roundabout method. Plus, I'm not sure how to generate points along the shoreline without manually digitizing a line and creating points along it.

Edit: After finding some sources on how to connect points to a nearby line, this issue is more of a question of workflow: How to 1) Create some reference vector layer for the shoreline, and 2) How to find the shortest route between points and that vector layer. This process has been answered below by Tom Brennan.

1
  • 6
    If the shoreline is at elevation 0, can you (1) run the Contour tool over the DEM (2) extract the 0 elevation lines only (3) calculate shortest distance from point to line? Oct 26, 2023 at 2:14

1 Answer 1

4

Start by creating contours from the DEM (Contour tool from Processing Toolbox). I needed to "fudge" the starting level by a tiny positive amount (0.01) to get the lowest level contour. This will be data-dependent.

enter image description here

Select all of the contours with the lowest value and use Collect Geometries with Selected features only checked to group them into a single feature.

You can then use Geometry by expression on your point layer, with the following expression: make_line($geometry,closest_point(geometry(get_feature_by_id('Collected',1)),$geometry))

enter image description here

Noting that my "fjords" are a bit rough and ready!

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.