QGIS – Cutting Shapes with Multiple Non-Contiguous Lines

polygon-creationqgis

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?

Best Answer

  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

Edit

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