All Products
Search
Document Center

PolarDB:ST_Force3DZ

Last Updated:Mar 28, 2026

Forces a geometry into XYZ mode by adding a Z coordinate to every point that lacks one.

Syntax

geometry ST_Force3DZ(geometry geomA);

Parameters

ParameterDescription
geomAThe input geometry to convert.

Usage notes

  • If the geometry object does not contain z coordinates, the values of z coordinates of the output are specified as 0.

  • Supports circular strings, curves, polyhedral surfaces, and 3D objects.

Examples

Basic example

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

Convert a 2D polygon to 3D

All vertices receive Z = 0 because the input has no Z coordinates:

SELECT ST_AsEWKT(ST_Force3DZ(ST_GeomFromEWKT('POLYGON((0 0,0 5,5 0,0 0),(1 1,3 1,1 3,1 1))')));
                         st_asewkt
--------------------------------------------------------------
 POLYGON((0 0 0,0 5 0,5 0 0,0 0 0),(1 1 0,3 1 0,1 3 0,1 1 0))
(1 row)