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

Ester
  • 1
  • 2
  • 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 Jul 13 '22 at 07: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 Jul 13 '22 at 08:07
  • I need to know the distance from the points to the lines. I need the information on point. – Ester Jul 13 '22 at 09: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 Jul 13 '22 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 Jul 13 '22 at 11:49
  • There is no screenshot anywhere in the comments. It would be good if you could post a screenshot where we see what you do: how are the names of your layers, where do you want to apply the expression, what should the result look like etc. Simply providing an expression does not help much. Please edit your initial question and post any addition there, not in the comments. – Babel Jul 13 '22 at 12:15
  • Try this: length ( make_line( $geometry , closest_point( overlay_nearest ( 'ADAMO_11', $geometry )[0] , $geometry ) )) – Babel Jul 13 '22 at 12:20
  • I have already modified the question with screenshots – Ester Jul 14 '22 at 07:11

1 Answers1

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.

Erik
  • 16,269
  • 1
  • 24
  • 43