[postgis-devel] [postgis-users] Split line at a given point

Paragon Corporation lr at pcorp.us
Tue Oct 20 11:46:14 PDT 2009


Kevin,
Hmm I was actually thinking it would be more useful if it can take a
multipoint because then you can pass in a collection of points and have it
clip the linestring at those junctures in a single go.

I was going to write up a function something along that line.

I'm not too crazy about the idea of having it included in PostGIS unless its
a C function as I can think of thousands of functions I could include like
this
,and the fact its written in plpgsql makes it tempting to change by PostGIS
users for their own particular usecase, thus greying the zone  of what is
allowed and not allowed to change in the PostGIS boundary.

A catalog of functions better organized than what we have -- perhaps
organzied along the idea of use case and flagging the required version of
PostGIS to use it, seems more suitable to me.

Thanks,
Regina

-----Original Message-----
From: postgis-devel-bounces at postgis.refractions.net
[mailto:postgis-devel-bounces at postgis.refractions.net] On Behalf Of Kevin
Neufeld
Sent: Tuesday, October 20, 2009 11:18 AM
To: PostGIS Development Discussion
Subject: Re: [postgis-devel] [postgis-users] Split line at a given point

This seems to be a common use case.  Would it make sense to capture
sequences like this to a function for introduction into PostGIS?  For
starters, this could be a simple plpgsql function (converted to C at a later
date if the need arises) that accepts a linestring and a point and returns a
multilinestring split at the given point. We already have the capability of
merging linestrings ....

Cheers,
Kevin

Paragon Corporation wrote:
> Shane,
>
> Use
> http://www.postgis.org/documentation/manual-svn/ST_Line_Locate_Point.h
> tml 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
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   
_______________________________________________
postgis-devel mailing list
postgis-devel at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-devel






More information about the postgis-devel mailing list