All Products
Search
Document Center

PolarDB:ST_Force4D

Last Updated:Mar 28, 2026

Forces a geometry to 4D (XYZM), padding any missing Z or M coordinates with 0.

Syntax

geometry ST_Force4D(geometry geomA);

Parameters

ParameterDescription
geomAThe input geometry.

Description

ST_Force4D converts any geometry to a 4D (XYZM) object:

  • If the input geometry does not contain Z and M coordinates, the values of Z and M coordinates of the output geometry object are set to 0.

  • This function supports circular strings and curves.

  • This function supports 3D objects and does not delete Z coordinates.

Examples

3D point — Z preserved as 3, M defaults to 0:

SELECT ST_AsEWKT(ST_Force4D(ST_GeomFromEWKT('POINT(1 2 3)')));
   st_asewkt
----------------
 POINT(1 2 3 0)
(1 row)

What's next

For other dimension-forcing functions in the same family, see:

  • ST_Force2D — strips Z and M coordinates, returning a 2D geometry

  • ST_Force3D — forces XYZ mode, setting Z to 0.0 if absent

  • ST_Force3DM — forces XYM mode, setting M to 0.0 if absent

  • ST_AsEWKT — formats a geometry as Extended Well-Known Text (EWKT)