I've got some linestrings covering a road network, and need to split them at the crossroads. Does anybody have any idea on how to do it?
I'm using QGIS 2.4, with a Postgis 2.1.3.
There is few resolutions of this issue, maybe there are few better ones but this two should do also:
'By hand' (in steps)
Cut every line with another line which intersects it
Create table road_1 as Select row_number() over() as ID, input.name, (st_dump(st_split(input.geom, blade.geom))).geom as geom from roads input join roads blade on st_intersects(input.geom, blade.geom);
Now you've got few too much lines cause every time you're splitting one line into 2 parts, so you have to delete all lines that are covering another smaller ones (Thats why ST_NODE exists)
delete from road_1 a where exists ( select 1 from road_1 b where a.id != b.id and st_coveredby(b.geom,a.geom) );
Splitting every line in point of intersection with another line is one of things you have to do to create road topology so maybe it'll be easiest to get familiar with function pgr_createTopology of PG Routing project.
This workshop could be helpfull