Skip to content
🎉 Apache Sedona 1.8.1 is now available! Check out the new features and improvements.

ST_Force4D

Introduction: 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.

Note

Example output is after calling ST_AsText() on returned geometry, which adds Z for in the WKT for 3D geometries

Format:

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

ST_Force4D(geom: Geometry

Since: v1.6.1

SQL Example

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))

Output:

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))

SQL Example

SELECT ST_AsText(ST_Force4D(ST_GeomFromText('LINESTRING(0 1,1 0,2 0)'), 3, 1))

Output:

LINESTRING ZM(0 1 3 1, 1 0 3 1, 2 0 3 1)