3

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 (?)

1

You can draw the requested line creating, still in Geometry Generator, a new LineString symbol layer with this expression

make_line (
make_point(x($geometry), y($geometry)),
make_point((x(point_n(buffer($geometry, "buffer"), 15)) ), ( y(point_n(buffer($geometry, "buffer"), 15)))))

This will create a line (red) that starts in your central point and terminates in the node 15 of the buffer. You can play with this number to turn the line in different point of the buffer, so changing the angulation.

enter image description here

| improve this answer | |

Your Answer

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

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