Skip to main content
Forces the geometry into XYM mode. Retains any existing M coordinate, but removes the Z coordinate if present. Assigns a default M value of 0.0 if mValue is not specified.
Example output is after calling ST_AsText() on returned geometry, which adds M for in the WKT.
ST_Force3DM

Signatures

ST_Force3DM(geometry: Geometry, mValue: Double = 0.0)

Parameters

geometry
Geometry
required
The input geometry.
mValue
Double
default:"0.0"
required
The M (measure) coordinate value to assign. Defaults to 0.0 if not specified.

Return type

The resulting geometry.

Examples

SELECT ST_AsText(ST_Force3DM(ST_GeomFromText('POLYGON M((0 0 3,0 5 3,5 0 3,0 0 3),(1 1 3,3 1 3,1 3 3,1 1 3))'), 2.3))
POLYGON M((0 0 3, 0 5 3, 5 0 3, 0 0 3), (1 1 3, 3 1 3, 1 3 3, 1 1 3))
SELECT ST_AsText(ST_Force3DM(ST_GeomFromText('LINESTRING(0 1,1 0,2 0)'), 2.3))
LINESTRING M(0 1 2.3, 1 0 2.3, 2 0 2.3)
SELECT ST_AsText(ST_Force3DM(ST_GeomFromText('LINESTRING Z(0 1 3,1 0 3,2 0 3)'), 5))
LINESTRING M(0 1 5, 1 0 5, 2 0 5)