[postgis-users] Break lines at intersections

Pavel Iacovlev iacovlev.pavel at gmail.com
Wed Mar 28 05:49:57 PDT 2012


As I understand from the code, this will create a node/point if my
line "self intersects", but I need to brake my line into N new lines
where it intersects with any other line from the same table.

On Wed, Mar 28, 2012 at 3:31 PM, Horst Düster <horst.duester at kappasys.ch> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi
>
> if you work with PostGIS < 2.0 you can use the cleangeometry() function.
>
> http://www.kappasys.ch/pgtools/cleangeometry/cleanGeometry.sql
>
> Regards
> Horst
>
> Dr. Horst Düster
> Kappasys
> Alte Bernstrasse 13
> CH-4500 Solothurn
>
> Tel.: +41 (0) 32 514 00 40
> Mobil: +41 (0) 76 408 51 06
> eMail: horst.duester at kappasys.ch
> skype: horstduester
> Twitter: moazagotl
> Web: www.kappasys.ch
>
> lat: N 47° 12' 06.408" lon: E 7° 32' 13.740"
>
> Am 28.03.2012 12:29, schrieb Pavel Iacovlev:
>> Hello,
>>
>> Anyone has any ideas/tips of how to break lines at intersections ?
>> I have a a layer of lines and I want to break them at intersections
>> with them selfs, also (not that important but would be nice) break
>> lines forming a collapsed loop, for example 0.0;1.0;0.0 is broken at
>> 1.0.
>>
>> Currently this can be done in grass with v.clean tool=break,rmdupl but
>> it's relatively hard to add GRASS to a web app.
>>
>> So far I came up with this query and out of ideas right now:
>>
>> SELECT DISTINCT
>> gid,
>> ST_AsText(intersect_geom),
>> ST_Line_Locate_Point(GeometryN(the_geom, 1), intersect_geom) as point_loc1
>> FROM
>>
>> (SELECT a.gid, ST_Intersection(a.the_geom, b.the_geom) AS
>> intersect_geom, a.the_geom
>> FROM roads as a, roads as b
>> WHERE ST_Intersects(a.the_geom, b.the_geom) AND (a.gid = 1)
>> ) AS res1
>>
>> WHERE GeometryType(intersect_geom) = 'POINT' -- Need support for
>> MULTILINESTRINGS, take start and end point ?
>> ORDER BY point_loc1
>>
>> which has the following result: http://jsfiddle.net/9RJ8a/
>> I have the line, and the point positions on the line, but I can't get
>> around how to create my NEW broken lines with
>> ST_Line_Substring(geometry a_linestring, float startfraction, float
>> endfraction)
>>
>> Any suggestion of how to accomplished this ? is the approach correct ?
>> any other ideas ?
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJPcwSiAAoJENJq1wkKM7pS6NwH/3PzIeSfjG29wfrPx4mLu7gS
> 6gAYWk6Lsfp4kUEoy6uJdtGz6iFn3vY2blz1cA9diUrjw00O8m5/8IVFuI0jdyLM
> j6tzDbyB7jmXyF6F3TLKfnAakVGenhbcXTeHRL3ojAiKcq8UGsRDQYviQ3WZK9sY
> EXP9wJIunhawILOfFXEO68AcRDPLZcaLtZAE/qj4yY+p538M/8PNfuK2rBw6fcVO
> dPcug4wDewciPYQBcgKdbRpXtpfh9ytq4xYV16aAA8wVg4lFicldIm4cm8mytOrb
> 0bYYyFmAHtpBQ2Hv6A7eMxywzF8iQmu8oPl1I6ihPwol3VQ/Tws+nAKbfGKs3bs=
> =FgwT
> -----END PGP SIGNATURE-----
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list