PostGISLinear Referencing

ST_LineInterpolatePoint

What is ST_LineInterpolatePoint?

ST_LineInterpolatePoint is a PostGIS function that returns the point located a specified fraction of the way along a linestring. The fraction runs from 0 (start) to 1 (end).

SQL
1ST_LineInterpolatePoint(geometry line, float fraction)geometry
2ST_LineInterpolatePoint(geography gline, float fraction, boolean use_spheroid = true) → geography

When would you use ST_LineInterpolatePoint?

Use ST_LineInterpolatePoint for linear-referencing tasks — placing a mile marker at 30 % along a road, computing the halfway point of a track for labelling, finding the midpoint of a boundary for placing features, or snapping a route to an arbitrary travel-distance offset.

SQL
1SELECT ST_LineInterpolatePoint(geom, 0.5) AS midpoint
2FROM routes
3WHERE id = 42;

FAQs

What does the fraction mean — distance or parameter?

The fraction is a 2D distance along the line divided by its total 2D length. So 0.5 is always the point at exactly half the linestring's length, not at the halfway vertex.

Does it handle MultiLineStrings?

No — the input must be a single LINESTRING. For multi-part inputs, dump to individual parts with ST_Dump or merge them with ST_LineMerge if they are contiguous.

Does the output carry M values?

If the input has M values, the output point inherits the interpolated M. This is useful when the linestring represents a measure-parameterised route (e.g. a kilometer post).

How do I get multiple evenly spaced points?

Use ST_LineInterpolatePoints(line, fraction) (plural). It returns a multipoint of points at every fraction step along the line — much more efficient than calling ST_LineInterpolatePoint many times.