Is there a way to generate a polygonal buffer on the end of an existing polygon in QGIS? The red polygon was added using MS Paint as an example of what I would like to achieve. Ideally, the red polygon would extend from the orange polygon from the center point (red vertex) - equally or similar to a buffer. It would be even better if the red polygon could maintain the width of the orange polygon. Not sure if this is possible or something Geometry by Expression could handle.
You can use QGIS expressions with Geometry Generator and this expression for rectangles - see screenshot at the bottom.
- If you want the "buffers" only on one side, in line 3 replace
(1)to get only one end or by
(-1)to get only the other end.
- In case you want the "buffers" on the long side of the rectangle, in line 18 change
radians (main_angle ($geometry))into
radians (main_angle( $geometry)-90)
collect_geometries ( array_foreach( array(-1,1), --change here to get buffers only at one end with_variable ( 'int', intersection ( boundary($geometry), make_line( centroid ($geometry), project ( centroid($geometry), @element* length ( make_line( centroid($geometry), point_n($geometry,1) ) ), radians (main_angle ($geometry)) -- change here to get buffers at the long side of rectangles ) ) ), make_regular_polygon( @int, project ( @int, length( make_line ( @int, closest_point ( nodes_to_points($geometry), @int ) ) ), radians (main_angle ($geometry)) ), 4, 1 ) ) ) )