This topic describes the ST_NDims function. This function returns the coordinate dimension of the input geometry object.
Syntax
integer ST_NDims(geometry g1);
Parameters
Parameter | Description |
---|---|
g1 | The geometry object that you want to specify. |
Description
- This function returns different coordinate dimensions when you specify different types
of geometry objects.
- If you specify a 2D object, this function returns the coordinate dimension in the (X,Y) format.
- If you specify a 3D object, this function returns the coordinate dimension in the (X,Y,Z) or (X,Y,M) format.
- If you specify a 4D object, this function returns the coordinate dimension in the (X,Y,Z,M) format.
- This function supports 3D objects and does not delete z coordinates.
Examples
- Results returned by specifying a 2D object:
SELECT ST_NDims('POINT(0 1)'::geometry); st_ndims ---------- 2 (1 row)
- Results returned by specifying a 3DM object and a 3DZ object:
SELECT ST_NDims('POINT(0 1 2)'::geometry) as _3DZ,ST_NDims('POINTM(0 1 2)'::geometry) as _3DM; _3dz | _3dm ------+------ 3 | 3 (1 row)
- Results returned by specifying a 4D object:
SELECT ST_NDims('POINT(0 1 2 3)'::geometry); st_ndims ---------- 4 (1 row)