Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Discussion options

You must be logged in to vote

union should do the trick:

import shapely

line = shapely.LineString([(1,1),(3,3)])
line2 = shapely.LineString([(1.5,1.5),(2,2)])

union = shapely.union_all([line, line2])
print(union)
for geom in union.geoms:
    print(geom)

Output:

MULTILINESTRING ((1 1, 1.5 1.5), (1.5 1.5, 2 2), (2 2, 3 3))
LINESTRING (1 1, 1.5 1.5)
LINESTRING (1.5 1.5, 2 2)
LINESTRING (2 2, 3 3)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@xiaojiuwo1993
Comment options

Answer selected by xiaojiuwo1993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants