3

How can I generate a projection of points on the nearest line?

I have a layer with several points and I have another layer with several lines. And I want to generate a projection of these points but creating points in these projections.

I found this picture online that illustrates what I want to do:

enter image description here

I want to create this projection but also create a point in the final projection (in the line) as a new layer with these points.

Babel
  • 71,072
  • 14
  • 78
  • 208

1 Answers1

3

If you don't mind using expressions, you can achieve this with geometry generator (for visualization purpose only) or with Menu Processing / Toolbox / Geometry by expression (if you want to create a new layer with the nearest points on the line). In both cases, the expression remains the same.

Let's suppose you have the same setting as on the screenshot below: a red line (layer named line) and the red points. To demonstrate it with geometry generator: On the points layer, you add a symbol layer (click the green + symbol), than set it to Geometry generator, as Geometry type select points and paste the following expression. It generates the blue points on the screenshot (I added the black lines connecting red and corresponding nearest blue point on the line for easier identification only):

closest_point (   
    geometry ( 
        get_feature_by_id ( 
            'line' , 1 
        ) 
    ) , 
    $geometry
)

QGIS expression closest point on line

Babel
  • 71,072
  • 14
  • 78
  • 208