I'm looking to create the geometry of a multi-lined label like so:

multilined label

However, I need a way for the width of the overall label to shrink as it get closer to the edge so that it doesn't end up going outside the label, like so:

enter image description here

I am using the label location as "offset from centroid" so if I can calculate the distance from the centroid to the edge of the polygon, I should be able to make the width of all four lines a percentage of the distance to the edge.

In short, I need an expression to calculate the distance of the visible centroid of a polygon to its edge (the blue line), as pictured below.

enter image description here

1 Answer 1


You could try an expression of the form:


exterior_ring gives the (outside) boundary of the polygon as a linestring, and distance calculates the shortest distance between two geometries.

Given the rest of your question, you may need to tweak this for edge cases, but it's probably a good starting point.

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.