If we decompose the MultiLineString, the result is:
for i in multiline:
print(i)
LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0) # green line
LINESTRING (0.5 0, 0.5 -1) # red line
LINESTRING (1.5 0, 2 2) # blue line
LINESTRING (3 0, 2 3) # purple line
We can see that the points (0.5,0, red) and (1.5,0, blue) are not nodes of the green line, even if the lines intersect/touche.
list(multiline[0].coords) # nodes of the green line
[(0.0, 0.0), (1.0, 0.0), (2.0, 0.0), (3.0, 0.0), (4.0, 0.0)]
print(list(multiline[0].intersection(multiline[1]).coords))
[(0.5, 0.0)] # not a node of the green line
print(list(multiline[0].intersection(multiline[2]).coords))
[(1.5, 0.0)] # not a node of the green line
As the splitting points are only on the green line (yellow points),
the result of splitres is normal. Only the green line is splitted, the others, red,blue and purple lines, remain untouched and,apart from intersections, there are no relationships between the lines (for MULTILINESTRING ((0 0, 1 0), (0.5 0, 0.5 -1))
or MULTILINESTRING ((1 0, 2 0, 3 0), (1.5 0, 2 2))
)
for i in splitres:
print(i)
LINESTRING (0 0, 1 0) # green line 1
LINESTRING (1 0, 2 0, 3 0) # green line 2
LINESTRING (3 0, 4 0) # green line 3
LINESTRING (0.5 0, 0.5 -1) # red line
LINESTRING (1.5 0, 2 2) # blue line
LINESTRING (3 0, 2 3) # purple line
A solution is to use the unary_union predicate. The solution will split all self-intersection geometries
print(unary_union(splitres))
MULTILINESTRING ((0 0, 0.5 0), (0.5 0, 1 0), (1 0, 1.5 0), (1.5 0, 2 0, 3 0), (3 0, 4 0), (0.5 0, 0.5 -1), (1.5 0, 2 2), (3 0, 2 3))
for i in unary_union(splitres):
print(i)
LINESTRING (0 0, 0.5 0)
LINESTRING (0.5 0, 1 0)
LINESTRING (1 0, 1.5 0)
LINESTRING (1.5 0, 2 0, 3 0)
LINESTRING (3 0, 4 0)
LINESTRING (0.5 0, 0.5 -1)
LINESTRING (1.5 0, 2 2)
LINESTRING (3 0, 2 3)