Fork me on GitHub

ST_Interpolate3DLine

Signature

GEOMETRY ST_Interpolate3DLine(GEOMETRY geom);

Description

Interpolate the z-values of geom based on the z-values of its first and last coordinates. Does an interpolation on each indiviual Geometry of geom if it is a GEOMETRYCOLLECTION.

Returns geom untouched if its first or last coordinate has no z-value.

Returns NULL if geom is not a LINESTRING or a MULTILINESTRING.

Examples

SELECT ST_Interpolate3DLine('LINESTRING(0 0 1, 5 0, 10 0 10)');
-- Answer:                   LINESTRING(0 0 1, 5 0 5.5, 10 0 10)

SELECT ST_Interpolate3DLine(
          'MULTILINESTRING((0 0 0, 5 0, 10 0 10),
                           (0 0 0, 50 0, 100 0 100))');
-- Answer: MULTILINESTRING((0 0 0, 5 0 5, 10 0 10),
--                         (0 0 0, 50 0 50, 100 0 100))
Nonexamples
-- Returns the Geometry untouched:
SELECT ST_Interpolate3DLine('LINESTRING(0 8, 1 8, 3 8)');
-- Answer: LINESTRING(0 8, 1 8, 3 8)

-- Returns NULL for Geometries other than LINESTRINGs and
-- MULTILINESTRINGs:
SELECT ST_Interpolate3DLine(
            'POLYGON((2 0 1, 2 8 0, 4 8, 4 0, 2 0))');
-- Answer: NULL
See also