# [Qgis-user] Calculating shortest distance and angle of line connecting a point and an area feature

Sat Jan 9 15:30:23 PST 2021

```Hi,

Open the vector file, open the field calculator, create a new field with
floats.  Cut and paste this formula.

(atan((xat(-1)-xat(0))/(yat(-1)-yat(0)))) * 180/3.14159 + (180
*(((yat(-1)-yat(0)) < 0) + (((xat(-1)-xat(0)) < 0 AND (yat(-1) - yat(0))
>0)*2)))

I think the new way to call the x of first node is: \$x_at(0) and not
xat(0) but the above works.

There must be an  easier way ...

NIcolas

On 2021-01-09 2:46 a.m., Alejandro Fernandez "Al" Tongco wrote:
> Thanks Nicolas for your time.
>
> I'm trying to use both stand-alone SAGA (Snap Points to Polygons) to
> produce the shortest line and QGIS to figure out the line angle
> (line_interpolate_angle).  As of now, I'm successful on the former but
> not on the latter yet.  I'll keep on trying...
>
> *Alejandro Fernandez "Al" Tongco*
>
>
>
>
> On Wednesday, December 30, 2020, 11:47:08 PM GMT+8, Nicolas Cadieux
>
>
> Hi,
> You can use the saga tool snap points to lines found in the
>  processing toolbox. Then ask for the option to create the distance
> line (moves) and not the new points.  From that new line file, you can
> find the angle (azimut) of the line using an expression using the
> field calculator.
>
> https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/functions_list.html#line-interpolate-point
> <https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/functions_list.html#line-interpolate-point>
>
>
>> Le 30 déc. 2020 à 02:13, Alejandro Fernandez "Al" Tongco
>> <al_tongco at yahoo.com> a écrit :
>>
>> ﻿
>> Hello qgis users,
>>
>> I need help how to calculate shortest length and angle of line
>> connecting a point and an area feature.  I'm using QGIS 3.16 in
>> Windows 10.
>>
>>
>> Al
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
--