Skip to main content
added 854 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

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

Input:
input

Output:
outputoutput1

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

Input:
input

Features with holes in which an area is more than 300 will be filled.

Output:
output2

It is possible to fill holes in polygon features using the following expression in the "Geometry by expression":

make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )

Input:
input

Output:
output

It is also possible to solve the same 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
                )
            )
        )
    )

Input:
input

Output:
output1

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

Input:
input

Features with holes in which an area is more than 300 will be filled.

Output:
output2

added 33 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

It is possible to fill holes in polygon features using the following expression in the "Geometry by expression":

make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )
make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )

Input:
input

Output:
output

It is possible to fill holes in polygon features using the following expression in the "Geometry by expression":

make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )

Input:
input

Output:
output

It is possible to fill holes in polygon features using the following expression in the "Geometry by expression":

make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )

Input:
input

Output:
output

added 6 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

In the Field Calculator itIt is possible to fill holes in polygon features using the following expression in the "Geometry by expression":

make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )

Input:
input

Output:
output

In the Field Calculator it is possible to fill holes in polygon features using the following expression:

make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )

Input:
input

Output:
output

It is possible to fill holes in polygon features using the following expression in the "Geometry by expression":

make_polygon(
    array_first(
        geometries_to_array(
            order_parts(
                boundary($geometry),
                'area(make_polygon(boundary($geometry)))',
                False
                )
            )
        )
    )

Input:
input

Output:
output

Source Link
Taras
  • 34k
  • 4
  • 73
  • 148
Loading