[GIS] Split Lines at Intersection of Other Lines

geoprocessingopenjumpqgisvector

I have two line layers (roads and contours in this example) and I would like to split the roads layer every time it crosses/intersects a feature on the contour layer. I can't seem to find a tool that does this, as the intersect tool is expecting a polygon for at least one of the layers. It also appears that GRASS' v.clean only works on a single layer. It seems like a simple task, but I'm at a loss!

EDIT (per comments below): Trying to get this to work in PostGIS now, and having some very strange results. If I do a subset of my dataset (one road, one contour that crosses it), and use the following SQL, I get the expected result, with the road split where the contour crosses it:

insert into "road_split"
select 
(ST_Dump(st_split(r.geom,c.geom))).geom
from "road" r, "contour" c

However, if I do the exact same thing with the complete dataset, no roads are split. What am I doing wrong here?

I should note that all features in both the road and contour table are LINESTRINGS.

Best Answer

Note that as of QGIS 2.8, there's a new tool in Processing Toolbox called "Split lines with lines" that does exactly this task and works beautifully.

Related Question