Name

ST_AddMeasure — Interpolates measures along a linear geometry.

Synopsis

geometry ST_AddMeasure(geometry geom_mline, float8 measure_start, float8 measure_end);

Description

Return a derived geometry with measure values linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.

Availability: 1.5.0

This function supports 3d and will not drop the z-index.

Examples

Code
SELECT ST_AddMeasure(
'LINESTRING(1 0,2 0,4 0)',
1,
4) As ewelev;
Output
LINESTRING M (1 0 1,2 0 2,4 0 4)
Figure
Geometry figure for visual-st-addmeasure-01
Code
SELECT ST_AddMeasure(
'LINESTRING(1 0 4,2 0 4,4 0 4)',
10,
40) As ewelev;
Output
LINESTRING ZM (1 0 4 10,2 0 4 20,4 0 4 40)
Figure
Geometry figure for visual-st-addmeasure-02
Code
SELECT ST_AddMeasure(
'LINESTRINGM(1 0 4, 2 0 4, 4 0 4)',
10,
40) As ewelev;
Output
LINESTRING M (1 0 10,2 0 20,4 0 40)
Figure
Geometry figure for visual-st-addmeasure-03
Code
SELECT ST_AddMeasure(
'MULTILINESTRINGM((1 0 4, 2 0 4, 4 0 4),(1 0 4, 2 0 4, 4 0 4))',
10,
70) As ewelev;
Output
MULTILINESTRING M ((1 0 10,2 0 20,4 0 40),(1 0 40,2 0 50,4 0 70))
Figure
Geometry figure for visual-st-addmeasure-04