Hi Daniel
Thanks for the suggestion. I wanted to exclude the cutline but I found that "
if not ls2.contains(item):" was not always reliable for complex linestrings so
this is what I have done:
from shapely.geometry import LineString
from shapely.ops import cascaded_union
ls1 = LineString([(0,0), (10,10)])
ls2 = LineString([(10,0), (0,10)])
ls2p = ls2.buffer(0.1)
cu = cascaded_union([ls1, ls2])
for item in cu.geoms:
if not item.within(ls2p):
print item
Cheers,
Robert
>>> "Harasty, Daniel J" <[email protected]> 3/04/2014 2:15 a.m. >>>
Robert,
This will give you all the cut-up parts:
from shapely.geometry import LineString
from shapely.ops import cascaded_union
ls1 = LineString([(0,0), (10,10)])
ls2 = LineString([(10,0), (0,10)])
cu = cascaded_union([ls1, ls2])
print "cut-up lines:"
for item in cu.geoms:
print item
Note that if you consider ls2 the "cut line", and you *don't* want it in the
output, you'll have to do a bit more work:
print "cut-up lines excluding the cut line:"
for item in cu.geoms:
if not ls2.contains(item):
print item
Hope that helps!
DJH
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Robert Sanson
Sent: Tuesday, April 01, 2014 8:44 PM
To: gispython.org community projects
Subject: [Community] Code for splitting a line with another line
Hi
Does anyone have some Python code for splitting an input line with another
intersecting cut line into two separate lines?
Many thanks,
Robert Sanson
This email and any attachments are confidential and intended solely for the
addressee(s). If you are not the intended recipient, please notify us
immediately and then delete this email from your system.
This message has been scanned for Malware and Viruses by Websense Hosted
Security.
www.websense.com<http://www.websense.com>
_______________________________________________
Community mailing list
[email protected]<mailto:[email protected]>
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community