# ST_Dimension function

The ST_Dimension function takes a geometry as an input parameter and returns its dimension.

If the given geometry is empty, then -1 is returned. For points and multipoints, the dimension is 0 (zero); for curves and multicurves, the dimension is 1; and for polygons and multipolygons, the dimension is 2. If the given geometry is null, then null is returned.

This function can also be called as a method.

## Syntax

## Parameter

- geometry
- A value of type ST_Geometry that represents the geometry for which the dimension is returned.

## Return type

INTEGER

## Example

This example creates several different
geometries and finds their dimensions.

```
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_geoms (id char(15), geometry ST_Geometry)
INSERT INTO sample_geoms VALUES
('Empty Point', ST_Geometry('point EMPTY',0))
INSERT INTO sample_geoms VALUES
('Point ZM', ST_Geometry('point zm (10 10 16 30)' ,0))
INSERT INTO sample_geoms VALUES
('MultiPoint M', ST_Geometry('multipoint m (10 10 5,
50 10 6, 10 30 8)' ,0))
INSERT INTO sample_geoms VALUES
('LineString', ST_Geometry('linestring (10 10, 15 20)',0))
INSERT INTO sample_geoms VALUES
('Polygon', ST_Geometry('polygon((40 120, 90 120, 90 150,
40 150, 40 120))' ,0))
SELECT id, ST_Dimension(geometry) Dimension
FROM sample_geoms
```

Results:

```
ID DIMENSION
--------------- -----------
Empty Point -1
Point ZM 0
MultiPoint M 0
LineString 1
Polygon 2
```