2

I currently use the Geometry Generator styling on a point layer to draw the intersection between protection buffers around tree points and another polygon (say a building footprint) using the following expression:

difference(buffer($geometry,"buffer"),
           aggregate('building_footprint_layer','collect',$geometry))

The style typically calls for a line from the tree point to some edge of the polygon to make it clear which tree is connected to which polygon.

Currently I can achieve this on these irregular polygons using shortest_line(), which is useful (see blue lines in image below).

(intersection() would be another option per another question of mine)

enter image description here

But I would also like to draw a line from the tree point to the furthest edge of the resultant polygon so I can slap a label on it and indicate what the protection buffer radius is (outside of the intersection with the building polygon). See black lines in image above.

Keeping in mind that

  1. The point will always be within the buffer polygon
  2. Intersections with the building polygon can be at any angle so I can't just draw a line at say 45° and take the intersection of that.
  3. The final angle of the longest line to the polygon doesn't matter much

Is there any way to achieve this using expressions and the Geometry Generator style? I have a feeling a custom Python function would be required; my understanding is that finding the longest linear distance from a point to a polygon boundary would require some kind of sweeping algorithm (?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.