# Create radius line and label the length to a buffer geometry generated

From a point geometry layer, I'm using an expression with buffer function as shown in the screenshot below:

I would like to add two more expressions to this point geometry layer:

1. An expression for Symbology to draw the radius line
2. An expression for Labels to add the length value of the radius

The expression that creates the buffer is as follows:

``````buffer(
\$geometry,
array_mean(  -- lengths mean
array_foreach(
overlay_nearest( -- get nearest points
'POINT_LAYER',
\$geometry,
limit:=4
),
length(
make_line(
\$geometry,
@element
)
)
)
)
)
``````

I show a screenshot with the expected result:

• So you seem to know, how to generate geometries using expression. What is keeping you from using `make_line()`?
– Erik
Apr 6 at 7:14
• I have made an approximation with this expression but I think it is not the correct solution. I think the hard part is to get a line to the edge of the buffer: shortest_line ( collect_geometries ( overlay_nearest( -- get nearest points 'BUFFER', \$geometry, --max_distance:=1000, limit:=4 ) ), \$geometry ) Apr 6 at 7:41
• The result that appears in the screen capture of the expected result is a hand-drawn simulation. It is not the application of the shortest line function. Apr 6 at 7:44

For the radial line (a Geometry Generator symbol layer):

``````with_variable(
'buffer_dist',           -- store result of distance calculation as a variable
array_mean( -- lengths mean
array_foreach(
overlay_nearest( -- get nearest points
@layer,
\$geometry,
limit:=4
),
length(
make_line(
\$geometry, @element
)
)
)
),

make_line(
\$geometry,
project(
\$geometry,
@buffer_dist,   -- insert the calculated value as a variable
)
)
)
``````

For the label position (Geometry Generator placement):

``````with_variable(
'buffer_dist',
array_mean( -- lengths mean
array_foreach(
overlay_nearest( -- get nearest points
@layer,
\$geometry,
limit:=4
),
length(
make_line(
\$geometry, @element
)
)
)
),

project(
\$geometry,
@buffer_dist / 2,
)
)
``````

The label expression:

``````array_mean( -- lengths mean
array_foreach(
overlay_nearest( -- get nearest points
@layer,
\$geometry,
limit:=4
),
length(
make_line(
\$geometry, @element
)
)
)
)
``````

Result:

• You have an attribute field that determines the buffer distance in the point layer?
– Matt
Apr 6 at 8:04
• See update. I store the result of Kadir's expression as a variable and then use it to create the line and to position the label.
– Matt
Apr 6 at 8:26
• Please include important information, like the fact the buffers are created 'on-the-fly', and the expression to do so, in your question, rather than added as comments. It's clearer when all the essential details are in one place.
– Matt
Apr 6 at 8:32
• A point has no extent, hence 0 bounds @Acperience
– Erik
Apr 6 at 8:50
• No, hence I removed it from my answer. The label expression is essentially the expression of Kadir, without the buffering part. I have added it above.
– Matt
Apr 6 at 9:08