Spent hours on a search. No luck. I need to create a border around selected adjacent polygons. Concave Hull and Convex Hull don't give the desired results. It seems to be a simple request. The problem is when you deal with thousands of them. Please see before and after image attached.
1 Answer
If you need it only for visualization purposes, you can use the first soution. Below you find a second solution that works for visualization purpose as well as in the case you want to create actual geometries (polygon or line):
Solution 1:
Duplicate the layer
Set the layer style to
Inverted polygons
>Simple line
Check the box next to
Merge polygons before rendering (slow)
Screenshot: yellow - original polygon layer; blue: duplicated layer:
Solution 2:
You can use QGIS expressions to create a buffer around the outer boundary of the polygons. You can use either Geometry generator
or Geometry by Expression
(see here for details) with the following expression (replace 'my_layer'
with the name of your layer and adapt the size of the buffer - 800
in my example). You get a polygon - if you want to get a line instead, look to version B below:
difference(
buffer (
aggregate(
'my_layer',
'collect',
$geometry
),
800),
aggregate(
'my_layer',
'collect',
$geometry
)
)
Screenshot: demonstrating the solution using Geometry generator:
Version B
To get a line instead of a polygon, simply add a boundary ()
function and set the buffer value to something close to 0
(in my case: 1
):