8

I'm looking to create a line from centroid of a circle and label it with the radius using the geometry generator but don't know where to start. QGIS 2.18.15. I'm using the Ovals, Rectangles plugin to draw the circle.

2
  • Just FYI, I ran across this warning when searching for info on this plugin: "Be wary... That plugin has known issues and will cause your QGIS to get slower and slower over time." – ndawson
    – csk
    Commented May 15, 2018 at 18:05
  • You can also create circles by buffering a point layer, if you want to avoid any issues this plugin may cause.
    – csk
    Commented May 15, 2018 at 18:06

1 Answer 1

7

Draw line from centroid to edge

Add a symbol layer to the polygon layer style.

Style the new symbol layer as Geometry Generator type (line), with this expression:

make_line( centroid( $geometry), end_point( $geometry))

Label the line with the circle's radius

Label the layer with this expression:

distance( centroid( $geometry), end_point( $geometry))

enter image description here

Adjust label placement to suit your preference. Show here with

  • placement: offset from centroid
  • quadrant: upper right

More labeling tips:

  • use the round() function to reduce the number of decimal places

    round(distance( centroid( $geometry), end_point( $geometry)),2)

  • add units using the concatenate symbol ||

    distance( centroid( $geometry), end_point( $geometry)) || ' meters'

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.