Skip to main content
Converts the input geometry to 4D XYZM representation. Retains original Z and M values if present. Assigning 0.0 defaults if mValue and zValue aren’t specified. The output contains X, Y, Z, and M coordinates. For geometries already in 4D form, the function returns the original geometry unmodified.
Example output is after calling ST_AsText() on returned geometry, which adds Z for in the WKT for 3D geometries
ST_Force4D

Signatures

ST_Force4D(geom: Geometry, zValue: Double, mValue: Double)
ST_Force4D(geom: Geometry)

Parameters

geom
Geometry
The input geometry.
zValue
Double
The Z coordinate value to assign. Defaults to 0.0 if not specified.
mValue
Double
The M (measure) coordinate value to assign. Defaults to 0.0 if not specified.

Return type

The resulting geometry.

Examples

SELECT ST_AsText(ST_Force4D(ST_GeomFromText('POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))'), 5, 10))
POLYGON ZM((0 0 2 10, 0 5 2 10, 5 0 2 10, 0 0 2 10), (1 1 2 10, 3 1 2 10, 1 3 2 10, 1 1 2 10))
SELECT ST_AsText(ST_Force4D(ST_GeomFromText('LINESTRING(0 1,1 0,2 0)'), 3, 1))
LINESTRING ZM(0 1 3 1, 1 0 3 1, 2 0 3 1)