0

I'm looking to label a series of lines based on a direction of the trail rather than any cardinal direction (east to west, north to south, etc.) in QGIS 3.4 for Windows 11.

For example, let's say I have an island: enter image description here

And I have some lines that follow the coastline. The distance between each line varies. enter image description here

I want to walk each line in the direction of northwest down to the tip in the southeast, then follow the coast up north again to the northeastern corner of the island. enter image description here

So that the labels would go from A to O from the northwest, down to the south, and up to the northeast. While this example uses letters, I'm planning on using numbers instead. enter image description here

I've seen this answer, but this is to follow points in a longitudinal direction (though it can be applied to latitudinal as well). This doesn't necessarily apply in my case as I'm (1) looking to do this for lines rather than points (so can't add a longitude field) and (2) I'm not following a single cardinal direction.

This is just an example with data that's quite limited. The actual number of lines I have exceed 200, so an automated (or semi-automated) way of doing this would be very helpful.

I'm not much of a coder so I'm not really brave enough to open up the console (nor do I even know how to open the console).

3
  • 1
    Visually it's very clear, we follow the coast and your instructions, but how, just with data (just geometries ?) we supposed to do ? We can't use the lines proximity, in your example G is close to J and not H, so it won't work like that. If you don't have a field to sort in order the segments, IMHO, it will be difficult to answer. Coding is not magic. Jun 25 at 16:48
  • 1
    Perhaps, you can generate the coastline (line layer) and the starting point. And then find something with distance from start point?
    – katagena
    Jun 25 at 17:09
  • 2
    You're asking others to create a solution that will require more them than it would probably need you do to it manually. The midway option would be to do a direction line then perform an operation that uses the distance along the line (or vertex ) to numerate things.
    – Al rl
    Jun 25 at 17:09

1 Answer 1

1
  1. Manually draw a direction line. It can be simply drawn with few vertices, see my dotted red line below.
  2. Densify this by interval to create vertices with short interval. My red line is 6000 m, I use 50 m interval
  3. Extract the vertices to points. The points will have a vertex_index attribute. So the vertices at start of the dotted line will get lower index than the ones at the end.
  4. Join the vertex index field to the path lines with Join attributes by nearest
  5. Order by expression on the paths, using vertex_index field
  6. Use field calculator to calculate a label field. With @row_number you get 1, 2 ,3 ... With char(@row_number+65) you get letters:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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