PostGIS

ST_NDims

Prev

7.4. Geometry Accessors

Next

Name

ST_NDims — Returns the coordinate dimension of a geometry.

Synopsis

+integer +ST_NDims(+`geometry `+g1`)`;

Description

Returns the coordinate dimension of the geometry. PostGIS supports 2 - (x,y) , 3 - (x,y,z) or 2D with measure - x,y,m, and 4 - 3D with measure space x,y,z,m

check This function supports 3d and will not drop the z-index.

Examples

SELECT ST_NDims(ST_GeomFromText('POINT(1 1)')) As d2point,
    ST_NDims(ST_GeomFromEWKT('POINT(1 1 2)')) As d3point,
    ST_NDims(ST_GeomFromEWKT('POINTM(1 1 0.5)')) As d2pointm;

     d2point | d3point | d2pointm
---------+---------+----------
       2 |       3 |        3

See Also