Creating tangential lines at points along shoreline in QGIS

I want to create tangential lines for each point along a shoreline in QGIS, such as the dashed line I've hand-drawn.

These points are not randomly spaced, they each represent the angle at which each control point is measured along the shoreline.

• see transect in QGIS [Vector Toolbox in Processing] docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/…
– Mapperz
Commented May 17 at 16:04
• Oops! I meant tangential… I’m going to use the tangential lines (as shown) to create perpendicular lines to measure shoreline orientation, my bad!! The points along the shoreline are in one layer, and the points behind the shoreline are in a separate layer. Essentially, ignore every line and the control points NOT on the shoreline. I just need to make tangential lines for each point along the shoreline, like the dashed line is showing. Commented May 17 at 21:44

1 Answer

This can be achieved with a Geometry by Expression / Geometry Generator expression.

``````-- find the nearest line to the current point (change 'coast layer' for the name of your line layer)
with_variable('coast',
overlay_nearest('coast layer', @geometry)[0],

-- get the angle of the line at the current point
with_variable('angle',
line_interpolate_angle(
@coast,
line_locate_point(
@coast,
@geometry
)
),

-- use that angle to generate a tangent (50 m in either direction of the point in this case)
make_line(
project(@geometry, 50, radians(@angle)),
project(@geometry, 50, radians(@angle - 180))
)
)
)
``````