[postgis-users] Split line at a given point
Paragon Corporation
lr at pcorp.us
Mon Oct 19 18:05:51 PDT 2009
Shane,
Use
http://www.postgis.org/documentation/manual-svn/ST_Line_Locate_Point.html to
locate the % position it is on the line,
Then use ST_Line_substring
http://www.postgis.org/documentation/manual-svn/ST_Line_Substring.html
So for example
If you get 0.25 back from ST_Line_Locate_Point
The trick is the answer you get won't be exactly on the line so you then
need to do a ST_SetPoint on the other part
Then the answer you seek would be
So basically
Pt is the point
Line1 = ST_Line_SubString(the_geom, 0, ST_Line_Locate_Point(the_geom) )
Line2 = ST_Line_SubString(the_geom, ST_Line_Locate_Point(the_geom), 1)
http://www.postgis.org/documentation/manual-svn/ST_SetPoint.html
--This part is to get around floating point errors to force the two lines to
connect back at the juncture
Line2 = ST_SetPoint(Line2,0 , ST_EndPoint(Line1))
Leo
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Shane
Butler
Sent: Monday, October 19, 2009 6:51 PM
To: PostGIS Users Discussion
Subject: [postgis-users] Split line at a given point
Hi all,
I am trying to split a linestring into two linestrings at a given
(intersecting) point. Can anyone give me a hint? I have tried
ST_Difference(mylinestr,mypoint) but it just returns mylinestr...
Im using: "POSTGIS="1.3.5" GEOS="3.0.3-CAPI-1.4.2" PROJ="Rel. 4.6.1,
21 August 2008" USE_STATS"
Kind Regards,
Shane
_______________________________________________
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