Clipping a LineString with Another LineString in Shapely

I have two multi-segment LineString objects: base and clipper.
I know the clipper partially overlaps base.
However, they are not necessarily axis aligned and have floating point coordinates so any match is not bit-exact.
In addition, they may also be closed curves.

For example: in the figure:

  • base is a closed blue curve. It is partially occluded (overlapped) by;
  • clipper - the orange line segment.
    enter image description here

I want to clip (or split) base by clipper.

In the example I expect the result to be:
enter image description here

One easy way to do it with shapely is: base - clipper.buffer(tiny_tol).
This generally does what I need but the buffer removes an extra tiny_tol from adjacent non-overlapping edge segments of base - this is what I'd like to avoid.

Zooming in on the corner reveals this artifact:

enter image description here

I tried projecting clipper's end-points onto base and using substring(base) but this does not work with MultiLineStrings, does not properly handle arbitrarily oriented (i.e. reversed clipper) and has some ambiguity regarding the clip direction when the overlap is across a closed curve's start/end point.

Any suggestions for a something better and more robust?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum