On Tue, Aug 4, 2020 at 8:46 AM Martin Davis <[email protected]> wrote:

> A frequent question on GISSE is to find the LineString segment index
> containing the closest point to a given point, to allow inserting the
> closest point into the line using AT_AddPoint.
>

I just realized that ST_Snap does a nice job of inserting close points into
LineStrings in a single step:

SELECT ST_AsText( ST_Snap(
  'LINESTRING (1 2, 1 5, 1 9)',
  'POINT (1 3)',
  0.1
));

I have updated the GISSE posts (including this one [1] about snapping to
multiple points).

It would still be useful to be able to get the segment index for other use
cases.

[1]
https://gis.stackexchange.com/questions/41162/adding-multiple-points-to-a-linestring-in-postgis
<https://gis.stackexchange.com/questions/41162/adding-multiple-points-to-a-linestring-in-postgis/370537#370537>
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to