How to use the maup.adjacencies.OverlapWarning 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_adjacencies.py View on Github external
def test_warns_for_overlaps(self, squares_some_neat_some_overlapping):
        with pytest.warns(OverlapWarning):
            adjacencies(squares_some_neat_some_overlapping)
github mggg / maup / maup / adjacencies.py View on Github external
raise ValueError('adjacency_type must be "rook" or "queen"')

    index, geoms = zip(*iter_adjacencies(geometries))
    inters = GeoSeries(geoms, index=index, crs=geometries.crs)

    if adjacency_type == "rook":
        inters = inters[inters.length > 0]

    if warn_for_overlaps:
        overlaps = inters[inters.area > 0]
        if len(overlaps) > 0:
            warnings.warn(
                "Found overlapping polygons while computing adjacencies.\n"
                "This could be evidence of topological problems.\n"
                "Indices of overlaps: {}".format(set(overlaps.index)),
                OverlapWarning,
            )

    if warn_for_islands:
        islands = set(geometries.index) - set(i for pair in inters.index for i in pair)
        if len(islands) > 0:
            warnings.warn(
                "Found islands.\n" "Indices of islands: {}".format(islands),
                IslandWarning,
            )

    return inters