Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Result of Linestring intersection with Shapely #859

Open
isVoid opened this issue Dec 15, 2022 · 0 comments
Open

Inconsistent Result of Linestring intersection with Shapely #859

isVoid opened this issue Dec 15, 2022 · 0 comments
Assignees

Comments

@isVoid
Copy link
Contributor

isVoid commented Dec 15, 2022

Shapely/geos doesn't seem to merge touching segments. cuSpatial does.

In [1]: from shapely.geometry import *

In [2]: l = LineString([(0.0, 0.0), (3.0, 3.0)])

In [3]: l2 = LineString([(0.0, 1.0), (1.0, 0.0), (2.0, 2.0), (0.0, 0.0)])

In [4]: l.intersection(l2)
Out[4]: <MULTILINESTRING ((0 0, 0.5 0.5), (0.5 0.5, 2 2))>

This is likely due to how union works in shapely...

In [4]: shapely.union(LineString([(0.0, 0.0), (0.5, 0.5)]), LineString([(0.5, 0.5), (1.0, 1.0)]))
Out[4]: <MULTILINESTRING ((0 0, 0.5 0.5), (0.5 0.5, 1 1))>

In [5]: shapely.union(LineString([(0.0, 0.0), (0.75, 0.75)]), LineString([(0.5, 0.5), (1.0, 1.0)]))
Out[5]: <MULTILINESTRING ((0 0, 0.5 0.5), (0.5 0.5, 0.75 0.75), (0.75 0.75, 1 1))>

Originally posted by @isVoid in #852 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant