1

I am new to GIS, know really nothing about coding or GIS. I am using QGIS 3.6.2, for which is it apparently hard to find up-to-date user guides.

I have made a map that includes road files and site locations. I added points along the road to be able to find the closest points on the road to the sites. I got an output that gives me the closest points and their distances, but cannot figure out how to get a line between these two sets of points. The ultimate goal is to be able to determine distances between sites using these roads.

enter image description hereenter image description here

6
  • If you want to find the distance between points via the road network look for routing tools. This two blog posts might be a good place to start: qgistutorials.com/en/docs/3/basic_network_analysis.html and anitagraser.com/2019/07/07/… Jul 6 '21 at 12:49
  • Before I can use routing tools, I need to add the existing road network by connecting it to the sites. It is this connections, from nearest points on the road to the sites that I cannot figure out. I have a list of distances for each, but I cannot get that information to translate into lines.
    – jsilverman
    Jul 6 '21 at 12:54
  • Take a look at snapping points to a line gis.stackexchange.com/questions/237224/… Jul 6 '21 at 13:42
  • Thanks, but that is not what I am trying to do. I want to create new lines, that run from points to the points that were identified as the closest points on the existing lines (road shape file). The result would be brand new lines between the existing line to the points. This should be theoretically possible, as the distance to nearest point on line algorithm selects a point on the existing line. All I want is instead of just calculating the distance is to create a new line between those points.
    – jsilverman
    Jul 7 '21 at 7:37
  • I added a solution to create the lines you want. However, routing should work from the snapped points on the line as well - that's why it is unclear to me as well why you need this line - and for what.
    – Babel
    Jul 7 '21 at 8:39
1

Let's say you have a line layer called line and a point layer called points. To connect to points to the closest point on the line, use Menu Processing / Toolbox /& Geometry by expression (see documentation), set points as Input layer, select line for Output geometry type and insert this expression:

make_line (
    $geometry,  
    closest_point( 
        aggregate (
            'line', 
            'collect',
            $geometry
        ),
        $geometry
    )
)

Using the expression, here with geometryx generator for visualization purpose: enter image description here

1
  • Thank you! That looks like what I need. I will try to do that :)
    – jsilverman
    Jul 7 '21 at 8:41

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.