# How to calculate the azimuth of an offset point/line?

After receiving and answer to this question, I am stuck with another problem.

For context, my end goal is to assess windward/lee side of a forested edges (line segments) in respect to a dominant wind direction. Following the answer in the linked question, I have created an offset point on the inside edge of each line segment. I now am trying to evaluate these line segments based on the azimuth of the offset (segment midpoint to offset midpoint).

How can I reference the offset point in an expression in a field calculation on the original line segment?

How do I reference offset_point if it is in another layer?

If it is another feature in the same layer?

``````psuedocode:
offset_azimuth = degrees(azimuth(segment_midpoint, offset_point))
if(offset_azimuth = (windDir +/- 45), "Lee", "Windward")
``````

If I understood your question right, the azimuth you're looking for is the azimuth of the small red lines in the original answer. I created this line using the following expression on the layer with the resulting points (those inside the polygons). It includes the `overlay_nearest` function, available since QGIS 3.16. The first argument is the reference to a layer - in my case named `'exploded'` - rename it for the name of the layer you use:

``````shortest_line (
centroid (
array_first(
overlay_nearest(
'exploded',
\$geometry
)
)
),
\$geometry
)
``````

You can get the azimuth of this line using the function `azimuth(point_a,point_b)`, where `point_a` is the start- and `point_b` the endpoint of the line created above. To avoid repeating the whole expression from above, add the function `with_variable(name,value,expression)` to define the line as a custom variable @line that you than can use with `start_point (@line)` and `end_point (@line)`.

Finally, the `azimuth` function retunrns the azimuth in radians - you probably want to convert it to degrees, so convert the whole expression with the function `degrees(radians)`.

The final expression looks like this:

``````degrees(
with_variable(
'line',
shortest_line (
centroid (
array_first(
overlay_nearest(
'exploded',
\$geometry
)
)
),
\$geometry
),
azimuth (
end_point (@line),
start_point (@line)
)
)
)
``````

Here is how the degree is calculated: I used the expression from above to define a label (I added a round function to round it to one decimal): • how do I integrate this into a graphical model? I don't know how to reference a algorithm output in place of 'exploded' Feb 28 at 21:02