Skip to content

ST_LineLocatePoint

Returns the location of the closest point on a LineString as a fraction of its total length.

Usage

double ST_LineLocatePoint(geomA: geometry, geomB: geometry)

Arguments

  • geomA (geometry): Input geometry
  • geomB (geometry): Input geometry

Description

Returns a double between 0 and 1, representing the location of the closest point on the LineString as a fraction of its total length. The first argument must be a LINESTRING, and the second argument is a POINT geometry.

Examples

SELECT ST_LineLocatePoint(
    ST_GeogFromText('LINESTRING(0 0, 1 1, 2 2)'),
    ST_GeogFromText('POINT(0 2)')
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_linelocatepoint(st_geogfromtext(Utf8("LINESTRING(0 0, 1 1, 2 2)")),st_geo │
│                        gfromtext(Utf8("POINT(0 2)")))…                       │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                           0.5004189059255194 │
└──────────────────────────────────────────────────────────────────────────────┘