I am unsure if this is the fastest way to test if LineStrings cross each other. Is there a better method.

for line_1, line_2, in itertools.combinations(lines, 2):
    crosses = line_1.crosses(line_2)
    if crosses is True:
         print(line_1, line_2)

Obviously this gets pretty slow with large files, I have found maybe loading it into an rtree index may speed this up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.