3

I am new to QGIS Plugins and I got something that has stressed me a lot. I want to have a layer(Linear) split whenever it intersects another feature (in another layer). I have tried with the one at:

Split a feature when intersecting with a feature of another layer using PyQGIS/Python?

and it works well. However, I want to have it split the line and not the polygon. Any help?

Wanjohi254
  • 109
  • 9
  • 1
    If you want to split a line with another line, you could look at the source code for the Split lines with lines algorithm :) – Joseph Mar 29 '17 at 11:56
  • Thanks Joseph for the quick response. Have checked this and the issue that might be complicating issues is that, I need to split, form a shapefile(layer) and load it on canvas.I think this is where it's getting tough – Wanjohi254 Mar 29 '17 at 12:02
  • 1
    @Wanjohi254 Did you try the Split lines with lines algorithm available from the Processing Toolbox? It seems to do what you are looking for. – mgri Mar 29 '17 at 13:01
  • Oh my. I was so much into coding my own algorithm. Hadn't seen this @mgri Thank you. What if I want to split the lines using points? – Wanjohi254 Mar 29 '17 at 13:08
  • @Wanjohi254 You're welcome. If this hint solved your issue, I will post it as an answer for helping potential future readers. – mgri Mar 29 '17 at 13:10
  • This is cool for splitting lines with lines. For the lines and points? – Wanjohi254 Mar 29 '17 at 13:16
  • @Wanjohi254 I think it should be addressed as a new question because the approach will be necessarily different. It's quite impossible trying to simply match point and line coordinates because you practically always will have a missed intersection (since the point coordinates need to perfectly match the line feature). In my opinion, you should ask a new question by specifying what exactly are you looking for. – mgri Mar 29 '17 at 14:10
  • @mgri Thank you. Will figure it out. I will try something out and see how it goes. – Wanjohi254 Mar 29 '17 at 15:46

1 Answers1

2

You may use the Split lines with lines algorithm available from the Processing Toolbox: its name is self-explanatory and I think it will solve your issue when dealing with lines.

For other kinds of geometries, I think the best would be to ask a separate question for each one because, otherwise, the topic would become too broad since every geometry type needs a different approach.

mgri
  • 16,159
  • 6
  • 47
  • 80