<div dir="auto">You could try finding the nearest point on the line to your input point, that would guarantee the point is on the line.  You could use st_closestpoint for that. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 25, 2021, 10:49 AM Nicol Hermann <<a href="mailto:postgis@geoworld.de" target="_blank" rel="noreferrer">postgis@geoworld.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello List,<br>
<br>
I am trying to split a linestring at an intersection to another line<br>
into it's two segments.<br>
This works as expected with "dummy" coordinates, but fails with "real-<br>
world" coordinates.<br>
<br>
This:<br>
<br>
SELECT ST_AsText( ST_Split (ST_GeomFromText('LINESTRING(0 0,2 2)'),<br>
ST_GeomFromText('POINT(1 1)') ) ) as lsegments;<br>
<br>
gives me the expected output:<br>
<br>
                          lsegments                          <br>
-------------------------------------------------------------<br>
 GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(1 1,2 2))<br>
(1 Zeile)<br>
<br>
<br>
When I am trying this with real world coordinates I am always getting<br>
the un-splitted original linesting back.<br>
Sample:<br>
<br>
SELECT ST_AsText(ST_intersection(aline, bline)) AS<br>
wktcut                                                                 <br>
<br>
FROM (SELECT<br>
    ST_GeomFromText('LINESTRING(8.39567520433486<br>
49.4224277276901,8.39591232763397 49.4198517063953)') As aline,<br>
    ST_GeomFromText('LINESTRING(8.39481293779266<br>
49.4206708596104,8.39717339245195 49.4208001995917)') As bline ) As<br>
foo;<br>
<br>
returns<br>
POINT(8.39583178549713 49.4207266868819)<br>
<br>
If I am using this in the split command<br>
<br>
SELECT ST_AsText( ST_Split<br>
(ST_GeomFromText('LINESTRING(8.39567520433486<br>
49.4224277276901,8.39591232763397 49.4198517063953)'),<br>
ST_GeomFromText('POINT(8.39583178549713 49.4207266868819)') ) ) as<br>
lsegments;<br>
<br>
the result is <br>
lsegments                                              <br>
----------------------------------------------------------------------<br>
 GEOMETRYCOLLECTION(LINESTRING(8.39567520433486<br>
49.4224277276901,8.39591232763397 49.4198517063953))<br>
(1 Zeile)<br>
<br>
which es equal to the input.<br>
<br>
Is this a precision issue between differen postgis functions and how<br>
can I solve this?<br>
<br>
If I'am adding ST_Snap it returns a linestring which only represents<br>
one of the 2 segments I would expect.<br>
<br>
See:<br>
<br>
SELECT <br>
 ST_AsText( <br>
  ST_Split ( <br>
   ST_Snap ( <br>
     ST_GeomFromText('LINESTRING(8.39567520433486<br>
49.4224277276901,8.39591232763397 49.4198517063953)'),<br>
ST_GeomFromText('POINT(8.39583178549713 49.4207266868819)'), 1 ), <br>
  ST_GeomFromText('POINT(8.39583178549713 49.4207266868819)') )<br>
);<br>
) ) <br>
as lsegments;<br>
<br>
response is:<br>
<br>
lsegemts                                               <br>
----------------------------------------------------------------------<br>
 GEOMETRYCOLLECTION(LINESTRING(8.39567520433486<br>
49.4224277276901,8.39583178549713 49.4207266868819))<br>
<br>
<br>
Any hints, or do I have a misconception how ST_Split should work?<br>
<br>
Thanks<br>
Nicol<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" rel="noreferrer noreferrer" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote></div>