2

I'm trying to generate transects using the QGIS transect tool under vector geometry as a step in generating an interpolation layer. Unfortunately, the transects are intersecting, which will lead to problems in subsequent steps. How can I trim the resulting transects so they don't intersect, or otherwise end up with the same result?

I can generate transects perpendicular to my source layer or a trend. Here I've used a smoothing and generalization routine to get transects following the trend: enter image description here But many of the transects cross if they are near any bends. How can I avoid these intersections in the transects, to get something similar to this:

enter image description here I could go through and manually trim each of the intersecting lines, but I'm looking for a more elegant/ less labor intensive solution.

1 Answer 1

1

Use the split with lines tool to split the transects lines wherever they cross each other. Use the transects layer as input for the input layer and the split layer.

enter image description here

The output will be a temporary layer called "Split."

Use the select by location tool to select all features in the Split layer that intersect the original line.

enter image description here

enter image description here

Save the selected features as a new layer.

Notes:

  • If you do this a lot you can do it faster by using the extract by location tool instead of select by location.
  • This method does produce lines that intersect at their endpoints. I assumed you wanted the lines to not cross each other. If you need them to not intersect at the ends, use the line substring tool to remove a very small amount from the start and end of each line.
    • Use a very small value for start distance, eg 0.0001
    • For end distance, subtract a small amount from the length of the line, eg $length - 0.0001
2
  • This worked well, but the split with lines task can take a while to process if you have many lines (for example if you smoothed lines before running the transect operation). Commented Oct 22, 2019 at 14:58
  • Good to know. If you do this process often, it might be worthwhile to put it into a graphical processing model so you can run it as one step. That way you can walk away from your computer while the model runs. Or you can run any of the individual algorithms on multiple layers at once (right click on the model name in the processing toolbox > run as batch process).
    – csk
    Commented Oct 22, 2019 at 17:30

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.