# Making buffer around crossing point on lines intersection in QGIS

I have two line layers A and B. I need to create a point at the intersection of these layers (which is not a science using "Line intersection").

Is there a possibility to draw a new one on line B at the point where it intersects with line A layer following line B on one and the other side of the intersection for a certain distance (e.g. 100 meters)?

This is the initial state:

We run Line intersections, we get a common point (as below in the picture)

And now what I want to as a result - creating a new line layer that would automatically draw a line on LayerA, for example. 100 meters to the left and 100 meters to the right, from the intersection point, following LayerA.

• A diagram, using your data and markup in Paint if necessary, would make this a great deal clearer. Please Edit the Question. May 14 at 20:43
• I will do it tomorrow in the morning...thx any way! May 14 at 20:49

You can use either of the following expressions - Either as a Geometry Generator symbol layer (on Layer B) or by using the Geometry by Expression geoprocessing tool if you wish to create a new layer with the results (used also on Layer B).

The first expression works for situations where there is only one intersection point per feature on Layer B. The second expression works when there are multiple intersection points per feature on Layer B.

#### Single intersection point per feature

``````-- find the intersection of the line layers and assign it to a variable
with_variable('i',
intersection(
-- a small extension is applied to Layer A to ensure there is a true intersection with Layer B.
-- the extension is applied at both ends so that the direction of the line does not need to be known
aggregate('Layer A', 'collect', extend(@geometry, 1, 1)),
@geometry
),

-- get the distance of the intersection along Layer B's geometry
with_variable('dist_along',
line_locate_point(@geometry, @i),

-- generate the line that spans 100 m either side of the intersection
line_substring(@geometry, @dist_along - 100, @dist_along + 100)
)
)
``````

#### Multiple intersection points per feature

⚠️ Be aware: due to the nature of Geometry Expressions, this will create a MultiLineString with duplicated geometries. You will need to run Multipart to Singleparts and then Delete Duplicate Geometries on the output to clean it up.

``````-- find the intersection of the line layers and assign it to a variable
with_variable('i',
intersection(
-- a small extension is applied to Layer A to ensure there is a true intersection with Layer B.
-- the extension is applied at both ends so that the direction of the line does not need to be known
aggregate('Layer A', 'collect', extend(@geometry, 1, 1)),
@geometry
),

-- collect the array of geometries into a MultiLineString
collect_geometries(
-- loop through each intersection point per Layer B feature
array_foreach(
-- convert the MultiPoint intersection geometry into an array of geometries
geometries_to_array(@i),

-- find the distance of the intersection along the Layer B feature
with_variable('dist_along',
line_locate_point(@geometry, @element),

-- generate a line that follows Layer B spanning 100 m either side of the intersection
line_substring(@geometry, @dist_along - 100, @dist_along + 100)

)
)
)

)
``````

Note, when using either a Geometry Generator symbol layer or the Geometry by Expression tool, don't forget to set the output geometry type to `LineString / MultiLineString` or `Line` respectively.

• It works perfectly in one combination LayerA cuts LayerB, but not at all in the opposite. I can't find a probably trivial error at all. May 15 at 10:07
• Are you able to share a small sample of data with various combinations?
– Matt
May 15 at 10:16
• Please can you clarify which is Layer A and which is Layer B in your sample data, thanks.
– Matt
May 15 at 12:37
• Does my second expression solve your problem? It worked when I tested it on your data.
– Matt
May 15 at 17:59
• That's odd, it works for me on your sample data. Did you remember to change the name of the layer in the expression from `Layer A` to `VlakeFinal`?
– Matt
May 16 at 9:39