# creating lines (distances) from points within buffer - thousands of points and buffers

i'm trying to assess the connectivity of an arboreal species' pathway. i have (1) a vector layer with approximately 15,000 tree points and (2) a layer with a buffer created for each of these trees. each tree has a different buffer radius that shows the potential distance the species can travel from the tree; it is calculated based on the tree's vertical height and relative elevation.

i want to create a line vector shapefile that shows the potential connection from one tree to all the trees within its buffer, and to do that for every single one of the 15,000 trees that i have.

how do i do it on QGIS? i can't use arcgis as i have only the standard license for arcgis so i can't use the spatial analyst tools. i was thinking of using the "distance to nearest hub" tool and to use an expression (manually input a formula?) for the hub distance, but i've been unsuccessful thus far.

• Once you've computed a merged buffer you can intersect the points with the buffer and that will tell you what buffer area is reachable by that point. It won't tell you the tree-to-tree connections though. For that I think you will have to compute the distance matrix and create a vector layer via some python scripts. Commented Mar 4, 2019 at 11:03

You can make use of the virtual layers.

Go to `Layer/ Add layer/ add-edit virtual layer` and enter the following query. Replace `treePointLayer` and `treeBufferLayer` by the real layer name, and change the select field name (here `id`) by the real names.

``````SELECT treeFrom.id, treeTo.id, makeline(treeFrom.geometry, treeTo.geometry)
FROM treePointLayer treeFrom,
treePointLayer treeTo,
treeBufferLayer bufferFrom,
treeBufferLayer bufferTo
WHERE treeFrom.id = bufferFrom.id
AND treeTo.id = bufferTo.id
AND treeFrom.id != treeTo.id
AND ST_INTERSECTS(bufferFrom.geometry, bufferTo.geometry)
``````

Basically, it joins the points to their buffer, then it intersects the buffers and at last it returns a line between the two points associated to the buffers.

This will create two lines between two trees, in both directions. If you just want one, add the clause `AND treeFrom.id < treeTo.id`