How to use the maup.repair.holes_of_union function in maup

To help you get started, we’ve selected a few maup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mggg / maup / tests / test_holes.py View on Github external
# 0 0 0 0
        # 000 000

        geometries = geopandas.GeoSeries(
            [
                square_at(point)
                for point in product([0, 1, 2], [0, 1, 2])
                if point != (1, 1)
            ]
            + [
                square_at(point)
                for point in product([4, 5, 6], [0, 1, 2])
                if point != (5, 1)
            ]
        )
        result = holes_of_union(geometries)
        assert len(result) == 2
        squares = [square_at((1, 1)), square_at((5, 1))]
        assert (result[0].equals(squares[0]) and result[1].equals(squares[1])) or (
            result[1].equals(squares[0]) and result[0].equals(squares[1])
        )
github mggg / maup / tests / test_holes.py View on Github external
def test_raises_for_non_polygons(self):
        has_a_point = geopandas.GeoSeries([Point((0, 0)), square_at((0, 0))])
        with pytest.raises(TypeError):
            holes_of_union(has_a_point)
github mggg / maup / tests / test_holes.py View on Github external
def test_multiple_holes_of_union(self):
        # 00000
        # 0 0 0
        # 00000
        geometries = geopandas.GeoSeries(
            [
                square_at(point)
                for point in product([0, 1, 2, 3, 4], [0, 1, 2])
                if point not in [(1, 1), (3, 1)]
            ]
        )
        result = holes_of_union(geometries)
        assert len(result) == 2
        squares = [square_at((1, 1)), square_at((3, 1))]
        assert (result[0].equals(squares[0]) and result[1].equals(squares[1])) or (
            result[1].equals(squares[0]) and result[0].equals(squares[1])
        )
github mggg / maup / tests / test_holes.py View on Github external
def test_multiple_geometries(self):
        # 000
        # 0 0
        # 000
        geometries = geopandas.GeoSeries(
            [
                square_at(point)
                for point in product([0, 1, 2], [0, 1, 2])
                if point != (1, 1)
            ]
        )
        result = holes_of_union(geometries)
        assert len(result) == 1
        assert result[0].equals(square_at((1, 1)))
github mggg / maup / tests / test_holes.py View on Github external
def test_single_geometry(self):
        hole_coords = [(25, 25), (75, 25), (75, 75), (25, 75)]
        geometry = Polygon(
            [(0, 0), (100, 0), (100, 100), (0, 100)], holes=[hole_coords]
        )
        result = holes_of_union(geopandas.GeoSeries([geometry]))
        assert len(result) == 1
        assert result[0] == Polygon(hole_coords)