New answers tagged linestring
There is a spatial function called ST_Union that would help, but you may not have the right version of MySQL to use it. Here's a way that you can manipulate the WKT directly using GROUP_CONCAT. It will allow you to create a MULTILINESTRING. Alternatively, you could create a GEOMETRYCOLLECTION the same way. Note that you may run out of memory, so have a ...
Did you read http://postgis.net/docs/ST_Contains.html? ST_Contains — Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A. Creating SQL queries which construct geometry from WKT is a good and controlled way for testing the syntax select ST_Contains( ...
There is ST_LineMerge function http://postgis.net/docs/manual-2.0/ST_LineMerge.html You could try to serve all your rivers network as one MultiLineString ST_LineMerge(ST_Multi(St_Collect(geometry))) The result is also a MultiLineString with segments sewed together. So after ST_LineMerge you could get sewed segments via ST_Dump.
Not tested, but it might give you what you want. With intersections you get those ids and geometries that intersect with others. And the SELECT statement will ST_Union all of these records that intersect exactly with two other geometries. ST_Dump makes sure you don't get MultiLinestrings as a result. WITH intersections AS ( SELECT l1.id, ...
Top 50 recent answers are included