[postgis-users] Break lines at intersections

Sandro Santilli strk at keybit.net
Wed Mar 28 05:51:48 PDT 2012


On Wed, Mar 28, 2012 at 03:46:03PM +0300, Pavel Iacovlev wrote:
> Not quite sure if I understand how ST_Node works, but I don't need all
> the "line segments" of the linestring, I need the linestrings to brake
> (divided into multiple linestrings while retaining the id attribute
> preferably) where they intersect with other line in the same table.

That's what ST_Node should give you, wrapped into collection.
You could then use ST_Dump to explode the collection into
components.

> I have a attached a small image to represent what I need:
> Line 1 - will be divided into 3 lines
> Line 2 - will be divided into 2 lines
> Line 3 - will be divided into 2 lines

The single-line case is likely bogus unless you have GEOS-3.3.2 or higher.

--strk;

  ,------o-. 
  |   __/  |    Delivering high quality PostGIS 2.0 !
  |  / 2.0 |    http://strk.keybit.net - http://vizzuality.com
  `-o------'




More information about the postgis-users mailing list