5

On the picture below, I want to let my point connect to the line with the shortest distance and show the distance to me.

enter image description here

I tried NNjoin, MMQGIS, v.distance But I still can't get the distance.

How do I connect them and get the shortest distance?

enter image description here

After that, I used the field calculator, but I think the distance is wrong

enter image description here

I measured it by myself, is any details can tell me to calculate the distance?

7
  • 2
    did you try v.net.connect?
    – PieterB
    Commented Oct 22, 2018 at 8:27
  • Hi PieterB, thanks for your reply. I tried , it connected to the nearest place, but I want to get the distance ,
    – Jack
    Commented Oct 22, 2018 at 8:49
  • then you have to add a field to calculatie the length. You can do that with the fieldcalculator.
    – PieterB
    Commented Oct 22, 2018 at 9:04
  • Hey PieterB,I got some problem,how to messure the distance?
    – Jack
    Commented Oct 22, 2018 at 9:18
  • 2
    in your 1st picture I notice a layer called 'gps1'. I think this will be in wgs84. In the last picture I see in the measure-tool 'OTF off'. I think you are measuring in the wrongs crs, namely wgs84. This will give you the wrong results! Can you say which crs you are using?
    – PieterB
    Commented Oct 22, 2018 at 14:48

1 Answer 1

3

It is possible to create a line that joins points and line using the Geometry generator.

In the point layer symbology, select the Geometry generator and use this expression to create the shortest line between the two geometries

shortest_line($geometry, aggregate('Line0', 'collect', $geometry))

0

To know the distance between the two geometries, AKA the length of the shortest line, you can use this expression in the label expressions or use it in the Field calculator to create a new field with this information

length(shortest_line($geometry, aggregate('Line0', 'collect', $geometry))
)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.