PostGISLinear Referencing

ST_3DLineInterpolatePoint

What is ST_3DLineInterpolatePoint?

ST_3DLineInterpolatePoint is a PostGIS function that returns the 3D point located at a given fraction along a linestring, where the fraction is measured by 3D length (not 2D).

SQL
ST_3DLineInterpolatePoint(geometry line, float fraction)geometry

The input must be a 3D linestring (LINESTRING Z).

When would you use ST_3DLineInterpolatePoint?

Use ST_3DLineInterpolatePoint whenever elevation affects distance — flight paths, slope-aware routes on mountainous terrain, underground pipelines, or any route where the 2D projection underestimates the true travel distance.

SQL
1SELECT ST_3DLineInterpolatePoint(geom, 0.5) AS three_d_mid
2FROM flight_tracks
3WHERE id = 1;

FAQs

How is 3D length different from 2D length?

3D length incorporates the Z delta between vertices via the Pythagorean theorem: sqrt(dx² + dy² + dz²). A 100 m flat line has 2D and 3D length of 100 m; the same line climbing 100 m vertically has 3D length of ~141.4 m. 3D-aware interpolation uses the 3D length as its denominator.

Does the input have to be 3D?

Yes — the linestring must carry Z values. For 2D inputs, call ST_LineInterpolatePoint instead, or promote with ST_Force3D first (though that sets Z = 0 and defeats the purpose).

Does it preserve M values?

Yes. If the linestring has M, the interpolated point inherits the interpolated M. The interpolation parameter is still based on 3D length.

When would I prefer 2D interpolation?

When Z variation is negligible or when you specifically want a planimetric answer — for example, if you are labelling a map that ignores elevation. For terrain-aware placement in 3D scenes, prefer the 3D variant.