I would like to "merge" 2 networks of lines and these lines need to be split when they intersect. With pictures it should be clearer :

black and red networks merged network

What to do:

  • if a black line intersects a red line, they should be split
  • a line can be split in more than 2 parts
  • I would like to keep line IDs (for example, a red_line_001 can be split into red_line_001_01 + red_line_001_02 + red_line_001_03)


  • each network may have more than 100000 lines
  • the algorithm should be efficient
  • I need to do it in Python
  • If possible, I would like to use Shapely, OGR-GDAL and/or Fiona
  • If possible, it should work with more than 2 networks

I already did this work with PostGIS and it was quite efficient (but not generic and worked only for 2 networks). I do not want you to solve this problem for me, I just need some hints and advice about what is the best solution to my problem.

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.