To calculate the distances in a table:
First ensure that your buffers layer and trees layer have a field with a unique identifier. I used
Perform a spatial join between the trees and the buffers using a one-to-many join type. This will give you a new points layer where points are duplicated when they are within more than one buffer.
T23 now appears 3 times, in buffers
- Then use this expression in the Field Calculator on the joined layer:
centroid(geometry(get_feature( -- get the centroid of the buffer that matches the buffer_id of the joined point.
attribute:='buffer_id', -- 'buffer_id' in single quotes is the field name
value:="buffer_id"))) -- "buffer_id" in double quotes is the field value of the current joined point
Now each tree point has a distance to its corresonding buffer centroid:
(The lines are for visualisation purposes only)