Closed anastassiavybornova closed 2 weeks ago
Do we actually have those? I know that theoretically they may exist but do they in reality?
In Liege, we don't have any.
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
Yeah. Aware of those. We're so far dealing with them in the notebook.
I added a keyword argument to core.algorithms.common.continuity()
in #80 for dealing with duplicated by default.
I think this issue has now been resolved, but not sure in which commit / PR.
Let's keep it open. We should do something about it in the pipeline which we currently don't.
preprocessing step needed: we already remove duplicated linestrings but i think we're still missing (partial) removal of partially overlapping ones.