It is also possible to fill holes in polygon features usingsolve the following expression insame task using the "Geometry by expression": with a corresponding expression.
To fill all holes in polygon features :
make_polygon(
array_first(
geometries_to_array(
order_parts(
boundary($geometry),
'area(make_polygon(boundary($geometry)))',
False
)
)
)
)
To fill only holes with a certain area in polygon features :
if(
num_interior_rings($geometry) = 0,
$geometry,
coalesce(
sym_difference(
collect_geometries(
array_foreach(
array_filter(
array_foreach(
generate_series(1, num_interior_rings($geometry), 1),
interior_ring_n($geometry, @element)
),
area(make_polygon(@element)) > 300 -- specify the maximum area
),
make_polygon(@element)
)
),
$geometry),
$geometry
)
)
Features with holes in which an area is more than 300 will be filled.