How to use the maup.repair.close_gaps 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
def test_closes_gaps(self):
        # 001
        # 0 1
        # 001
        pacman = Polygon(
            [(0, 0), (0, 3), (2, 3), (2, 2), (1, 2), (1, 1), (2, 1), (2, 0)]
        )

        bar = Polygon([(2, 0), (2, 3), (3, 3), (3, 0)])

        geometries = geopandas.GeoSeries([pacman, bar])
        fixed = close_gaps(geometries, relative_threshold=None)
        assert fixed[1].equals(bar)
        assert fixed[0].equals(Polygon([(0, 0), (0, 3), (2, 3), (2, 0)]))
github mggg / maup / tests / test_holes.py View on Github external
def test_can_impose_relative_area_threshold(self):
        # 001
        # 0 1
        # 001
        pacman = Polygon(
            [(0, 0), (0, 3), (2, 3), (2, 2), (1, 2), (1, 1), (2, 1), (2, 0)]
        )

        bar = Polygon([(2, 0), (2, 3), (3, 3), (3, 0)])

        geometries = geopandas.GeoSeries([pacman, bar])
        fixed = close_gaps(geometries, relative_threshold=0.01)
        # Since the gap is more than 1% of the area, the gap is not closed
        assert fixed[1].equals(bar)
        assert fixed[0].equals(pacman)

        geometries = geopandas.GeoSeries([pacman, bar])
        fixed = close_gaps(geometries, relative_threshold=0.5)
        # Since the gap is less than 50% of the area, the gap is closed
        assert fixed[1].equals(bar)
        assert fixed[0].equals(Polygon([(0, 0), (0, 3), (2, 3), (2, 0)]))