Question: I have two layers, a line and a point layer.

I need to make a line layer which connects all the points to the nearest line feature. How can I do that?

Is there a plugin available for QGIS?
This is a very important tool which is missing in QGIS.

ArcView has this tool: ["Nearest Features"](http://www.jennessent.com/arcview/nearest_features.htm)

![](https://i.stack.imgur.com/nMzUe.jpg)

Answer: 
In QGIS I can suggest using a ["Virtual Layer"](https://docs.qgis.org/latest/en/docs/user_manual/managing_data_source/create_layers.html#creating-virtual-layers) through `Layer > Add Layer > Add/Edit Virtual Layer...`.

Let's assume we have two layers *'points'* and *'river'* with their corresponding attribute tables, see image below.

[![input](https://i.stack.imgur.com/oGzkg.png)](https://i.stack.imgur.com/oGzkg.png)

With the following query, it is possible to create new lines that will represent the connection between points to the nearest line features.

```sql
SELECT
    ST_ShortestLine(r.geometry, p.geometry),
    p.id AS pid,
    r.id AS rid,
    ROUND(ST_Length(ST_ShortestLine(r.geometry, p.geometry)), 6) AS distance
FROM
    points AS p, river AS r
WHERE
    distance < 0.5
GROUP BY
    p.id
ORDER BY
    MIN(distance)

```

*Note:*

* `WHERE distance < 0.5` specifies the longest acceptable distance between point to the line feature

The output Virtual Layer with its Attribute table will look as following

[![output](https://i.stack.imgur.com/VyfR4.png)](https://i.stack.imgur.com/VyfR4.png)
[The ClosestPoint](https://plugins.qgis.org/plugins/ClosestPoint/)  does what you are looking for, currently limited to selected features only. You can take a look at the code and modify it for your needs