Returns the coordinate dimension of a geometry object as an integer.
Syntax
integer ST_CoordDim(geometry geomA);Parameters
| Parameter | Description |
|---|---|
geomA | The geometry object to evaluate. |
Description
ST_CoordDim is an alias for ST_NDims. Both functions return the same result.
Supported geometry types: circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
Examples
The following query runs ST_CoordDim on geometries of different dimensions in a single statement, so you can compare results side by side:
SELECT
ST_CoordDim('POINT(1 0)') AS d2,
ST_CoordDim('POINT(1 0 1)') AS d3z,
ST_CoordDim('POINTM(1 0 1)') AS d3m,
ST_CoordDim('POINT(1 0 1 1)') AS d4;Output:
d2 | d3z | d3m | d4
----+-----+-----+----
2 | 3 | 3 | 4
(1 row)Notice that d3z and d3m both return 3, even though one uses Z coordinates and the other uses M (measure) coordinates.
该文章对您有帮助吗?