1

I have four points of interest for each plot, a line representing the segment that faces the road and the plots themselves for representation purposes (all of them share in common an unique "id" to differentiate each plot). It is needed to calculate the distance from each red point to the segment of the plot that faces the road for each plot.

I have tried "Distance to nearest hub", and "Point to line distances (SAGA)" but the problem in these cases is that the distance is calculated to the closest line (direction of the red arrows), and it does not take into consideration the unique "id" of each plot and its correct direction to measure distance (green arrows).

Is there any way to calculate the distance for each red point to their line counterpart?

The solution must be a tool that can be added to a model in Graphical Modeler. I can change the line into point with interpolation if it is needed.

Example:

enter image description here

Example of directions:

enter image description here

8
  • Have you tried using a filter or selection query prior to running the point to line distance tool? If you create a filter based on the point layer unique ID, as well as on the lines layer unique ID (which I assume are the same), then the point to line distance tool will always result in the intended outcome. You could then iterate over all unique ideas and merge the results.
    – PGerrits
    May 13 at 11:56
  • Sorry, but I am missing the red and green arrows. Could you provide a screenshot containing them?
    – Erik
    May 13 at 12:01
  • I have thought of some kind of iteration based on unique id, but there are thousands of features with each unique id and I do not know how to make this process repeatable for each feature in a graphical modeler. May 13 at 12:03
  • I have updated the question with the image with good directions to measure distance (green) and the directions that are taken into consideration (red). May 13 at 12:05
  • 1
    Check this thread : gis.stackexchange.com/questions/181636/…
    – Taras
    May 13 at 12:13

1 Answer 1

3

You can create a "Virtual Layer", that will join the two layers by plot "ID" then compute the distance:

Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the query:

SELECT pt.plotID, pt.id, 
       ST_Distance(pt.geometry, ln.geometry) AS distance
FROM point_layer AS pt
JOIN line_layer AS ln 
  ON pt.plotID = ln.plotID;
4
  • I think your query is not full in terms of N:M, however, it will work in terms of N:1.
    – Taras
    May 13 at 14:10
  • @Taras yes, I understood that there is a single "road face" segment per plot
    – JGH
    May 13 at 14:41
  • 1
    Regarding the "Virtual Layer in Graphical Modeler" check this : gis.stackexchange.com/q/240210/99589
    – Taras
    May 16 at 5:31
  • Thank you very much! The query works fine, now I am checking to implement in into graphical modeler! May 16 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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