4

How to extend lines to Bounding Box in QGIS as in the following image:

enter image description here
Figure 1: Lines

enter image description here
Figure 2: Lines extended to Bounding Box

Link to Shapefile of Bounding Box: https://drive.google.com/drive/folders/1jsJ8m2dG0DNwF1jepxpWzwfUVI5sVJJe?usp=sharing

Link to shapefile of lines: https://drive.google.com/drive/folders/1BQvrMiPillL5ubYsDHfEyoV9st12z0E9?usp=sharing

Taras
  • 32,823
  • 4
  • 66
  • 137
HansrajR
  • 537
  • 3
  • 7

2 Answers2

5

Use this expression with Geometry generator or Geometry by expression (see here for details and differences between these two options) - the expression is adapted to the data you provided (layer name: 'Bounding Box', distance to extend the line: 65):

intersection (
    extend (
        $geometry,65,65
    ),
    geometry (
        get_feature_by_id(
            'Bounding Box',0
        )
    )
)

enter image description here

Taras
  • 32,823
  • 4
  • 66
  • 137
Babel
  • 71,072
  • 14
  • 78
  • 208
5

It may not be the most elegant way. However, you use "Extend line" to extend lines by the distance of the longest edge of the polygon.

enter image description here

The output looks like this and you can clip by Polygon with the "Intersection" tool.

enter image description here

And the output looks like this enter image description here

Taras
  • 32,823
  • 4
  • 66
  • 137
Nil
  • 1,517
  • 8
  • 22
  • @babel Can I have your comments on the question: https://gis.stackexchange.com/questions/383999/how-to-calculate-optimum-buffer-distance-for-different-groups-of-parallel-close – HansrajR Jan 11 '21 at 13:46