Returns the fractional location of the closest point on a LineString to a given point.
Syntax
float8 ST_LineLocatePoint(geometry aLinestring, geometry aPoint);
float8 ST_LineLocatePoint(geography aLinestring, geography aPoint);Parameters
| Parameter | Description |
|---|---|
aLinestring | The LineString object. |
aPoint | The point object. |
Description
ST_LineLocatePoint returns a float8 value between 0 and 1 representing the position of the closest point on a LineString to the given point, expressed as a fraction of the total line length.
This function can be used to estimate the number of addresses.
Examples
geometry
SELECT ST_LineLocatePoint('LINESTRING(0 0,0 2)'::geometry, 'POINT(1 1)'::geometry);Result:
st_linelocatepoint
--------------------
0.5
(1 row)geography
SELECT ST_LineLocatePoint('LINESTRING(0 0,0 2)'::geography, 'POINT(1 1)'::geography);Result:
st_linelocatepoint
--------------------
0.5000746195163556
(1 row)The geography result differs slightly from the geometry result because it accounts for Earth's curvature.