Skip to content

Inconsistent Result of Linestring intersection with Shapely #859

Open
@isVoid

Description

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)

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status

    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Inconsistent Result of Linestring intersection with Shapely · Issue #859 · rapidsai/cuspatial