0

I am looking for the shortest distance between "n" points and lines. I've been searching (I'm new to Qgis) and I get the expression:

length( make_line ( $geometry, closest_point ( geometry ( get_feature_by_id ( 'Shape_1', array_to_string ( overlay_nearest ( 'ADAMO_11', $id ) ) ) ) , $geometry ) ) )

With the "geometry Generator" it only makes lines at the symbology level but I cannot process the data.

I have extracted the information from: QGIS 3.16.11 shortest distance between point and line via field calculator and overlay_nearest

I add two screenshots, in the second the value that appears is not in meters. (I checked it with the ruler)

enter image description here

enter image description here

The expression that you indicate in the comment returns values ​​but they are not in meters. I put it in the screenshot of the question.

enter image description here enter image description here

8
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Commented Jul 13, 2022 at 7:48
  • Your question is not clear: where do you want to have the information? On the point or on the line layer? You want to add a value for the length to the attribute table or you want to draw the lines?
    – Babel
    Commented Jul 13, 2022 at 8:07
  • I need to know the distance from the points to the lines. I need the information on point.
    – Ester
    Commented Jul 13, 2022 at 9:52
  • There is a screenshot that I can't see in the comments of the post and it is where the problem was fixed @babel
    – Ester
    Commented Jul 13, 2022 at 11:47
  • The expression I use is: length ( make_line( $geometry , closest_point( geometry( get_feature_by_id ( 'ADAMO_11', array_to_string( overlay_nearest ( 'ADAMO_11', $id ) ) ) ), $geometry ) ) ) But the preview is "null"
    – Ester
    Commented Jul 13, 2022 at 11:49

1 Answer 1

1

If you run join attributes by nearest with your pointlayer as first input and you line layer as second input, it will by default attach the attributes of the nearest line feature, as well as the distance to that feature, to your points.

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.