uscuni / simplification

Simplification of street network geometry
Other
9 stars 0 forks source link

remove partially overlapping linestrings #90

Closed anastassiavybornova closed 2 weeks ago

anastassiavybornova commented 1 month ago

preprocessing step needed: we already remove duplicated linestrings but i think we're still missing (partial) removal of partially overlapping ones.

martinfleis commented 1 month ago

Do we actually have those? I know that theoretically they may exist but do they in reality?

martinfleis commented 1 month ago

In Liege, we don't have any.

jGaboardi commented 1 month ago

There may be no "partially" overlapping, but there do seem to be duplicates.

==================================================================================== FAILURES =====================================================================================
____________________________________________________________________________ TestContinuity.test_basic ____________________________________________________________________________

self = <test_common.TestContinuity object at 0x13e386d50>

    def test_basic(self):
>       roads = core.algorithms.common.continuity(self.roads)

core/tests/test_common.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
core/algorithms/common.py:21: in continuity
    coins = momepy.COINS(roads)
../../../miniforge3/envs/py311_uscuni_simplification/lib/python3.11/site-packages/momepy/coins.py:102: in __init__
    self._best_link()
../../../miniforge3/envs/py311_uscuni_simplification/lib/python3.11/site-packages/momepy/coins.py:212: in _best_link
    self.angle_pairs[f"{edge}_{link1}"] = _angle_between_two_lines(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

line1 = [[682619.7584150723, 5612995.734446571], [682615.8486979452, 5612983.020049579]], line2 = [[682619.7584150723, 5612995.734446571], [682615.8486979452, 5612983.020049579]]

    def _angle_between_two_lines(line1, line2):
        """
        Computes interior angle between 2 lines.
            input:  line<x> ... list of 2 tuples (x,y);
                    line1 and line2 by definition share one unique tuple
                    (overlap in 1 point)
            returns:    interior angle in degrees 0<alpha<=180
                        (we assume that line1!=line2, so alpha=0 not possible)
        """

        # extract points
        a, b = tuple(line1[0]), tuple(line1[1])
        c, d = tuple(line2[0]), tuple(line2[1])

        # assertion: we expect exactly 2 of the 4 points to be identical
        # (lines touch in this point)
        points = collections.Counter([a, b, c, d])

        # make sure lines are not identical
        if len(points) == 2:
>           raise ValueError(
                "Lines are identical. Please revise input data "
                "to ensure no lines are identical or overlapping. "
                "You can check for duplicates using `gdf.geometry.duplicated()`."
            )
E           ValueError: Lines are identical. Please revise input data to ensure no lines are identical or overlapping. You can check for duplicates using `gdf.geometry.duplicated()`.

../../../miniforge3/envs/py311_uscuni_simplification/lib/python3.11/site-packages/momepy/coins.py:438: ValueError
martinfleis commented 1 month ago

Yeah. Aware of those. We're so far dealing with them in the notebook.

jGaboardi commented 1 month ago

I added a keyword argument to core.algorithms.common.continuity() in #80 for dealing with duplicated by default.

jGaboardi commented 2 weeks ago

I think this issue has now been resolved, but not sure in which commit / PR.

jGaboardi commented 2 weeks ago

Maybe https://github.com/uscuni/simplification/pull/146?

martinfleis commented 2 weeks ago

Let's keep it open. We should do something about it in the pipeline which we currently don't.