Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

ST_NDims

Focus mode
ST_NDims - Amazon Redshift

ST_NDims returns the coordinate dimension of a geometry. ST_NDims doesn't consider the topological dimension of a geometry. Instead, it returns a constant value depending on the dimension of the geometry.

Syntax

ST_NDims(geom)

Arguments

geom

A value of data type GEOMETRY or an expression that evaluates to a GEOMETRY type.

Return type

INTEGER representing the inherent dimension of geom.

If geom is null, then null is returned.

The values returned are as follows.

Returned value Dimension of input geometry

2

2D

3

3DZ or 3DM

4

4D

Examples

The following SQL returns the number of dimensions of a 2D linestring.

SELECT ST_NDims(ST_GeomFromText('LINESTRING(0 0,1 1,2 2,0 0)'));
st_ndims ------------- 2

The following SQL returns the number of dimensions of a 3DZ linestring.

SELECT ST_NDims(ST_GeomFromText('LINESTRING Z(0 0 3,1 1 3,2 2 3,0 0 3)'));
st_ndims ------------- 3

The following SQL returns the number of dimensions of a 3DM linestring.

SELECT ST_NDims(ST_GeomFromText('LINESTRING M(0 0 4,1 1 4,2 2 4,0 0 4)'));
st_ndims ------------- 3

The following SQL returns the number of dimensions of a 4D linestring.

SELECT ST_NDims(ST_GeomFromText('LINESTRING ZM(0 0 3 4,1 1 3 4,2 2 3 4,0 0 3 4)'));
st_ndims ------------- 4

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.