# ST_Centroid function

The ST_Centroid function takes a geometry as an input parameter and returns the geometric center, which is the center of the minimum bounding rectangle of the given geometry, as a point. The resulting point is represented in the spatial reference system of the given geometry.

If the given geometry is null or is empty, then null is returned.

This function can also be called as a method.

## Syntax

## Parameter

- geometry
- A value of type ST_Geometry or one of its subtypes that represents the geometry to determine the geometric center.

## Return type

db2gse.ST_Point

## Example

This example creates two geometries
and finds the centroid of them.

```
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_geoms (id INTEGER, geometry ST_Geometry)
INSERT INTO sample_geoms VALUES
(1, ST_Polygon('polygon
((40 120, 90 120, 90 150, 40 150, 40 120),
(50 130, 80 130, 80 140, 50 140, 50 130))',0))
INSERT INTO sample_geoms VALUES
(2, ST_MultiPoint('multipoint(10 10, 50 10, 10 30)' ,0))
SELECT id, CAST(ST_AsText(ST_Centroid(geometry))
as VARCHAR(40)) Centroid
FROM sample_geoms
```

Results:

```
ID CENTROID
----------- ----------------------------------------
1 POINT ( 65.00000000 135.00000000)
2 POINT ( 30.00000000 20.00000000)
```