I'm trying to cut a shape in QGIS with a set of lines that don't form a single continuous path - they define an edge without holes, but they overlap each other rather than terminating at exactly the start of the next line. I cannot figure out how to use these to cut a polygon - even if I merge the lines, the polygon isn't cut.

Below is a (bad) basic depiction of what I want. Note that the two lines are separate (though in the same multiline layer), and neither extends across the entire width of the polygon.

A bad basic diagram of what I want

How can I accomplish the above?

1 Answer 1

  1. Run Menu Processing / Toolbox / Split with lines with the line layer twice as Input layer and as Split layer. Like this, the lines get split at the point where they intersect.

  2. Select the two features that form the line you want to use for splitting the polygon (highlighted in yellow in the screenshot) and merge them - delete the other two small lines (red, the dangles).

  3. Now again run Split with lines, this time with the polygon as input layer and the rectified line as split layer.

enter image description here


See also here for a solution to the problem of the invalid line.

The line you provided in the comments has invalid geometries. Repair it to be able to use if for splitting. Convert from Multipart to singleparts. Then extend the single lines using Menu Processing / Toolbox / Geometry by expression with the expression extend( $geometry,1,1). Then use the resulting layer with the initial solution above.

Another (manual) solution is to convert the line from Multipart to singleparts, then manually snap the vertices of conncting start- and end-segments together. Like this, splitting becomes possible:

Activate snapping and use the vertex tool to move the end-vetex of one line to the start-vertex of the next line: enter image description here

  • This looks like the right answer, but step 3 doesn't seem to be doing anything. The input polygon is output unchanged. What could I be doing wrong?
    – Sjiveru
    Nov 13, 2021 at 1:41
  • Can you share your data? Maybe the polygon contains geometry errors?
    – Babel
    Nov 13, 2021 at 7:09
  • Sure - the data is North American countries in this data set: naturalearthdata.com/downloads/10m-cultural-vectors/…. The line I have goes from Mexico to Canada, and none of Mexico, the US, or Canada will split along it
    – Sjiveru
    Nov 13, 2021 at 12:56
  • Actually Mexico will split; the line wasn't quite outside the border. Is there a possibility that a merged line might have gaps?
    – Sjiveru
    Nov 13, 2021 at 14:26
  • Providing just the polygons does not help much: you should also provide the line you want to use to split. Otherwise, I don't have any idea how it looks and where it goes.
    – Babel
    Nov 13, 2021 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.