# ST_ToMultiPolygon function

The ST_ToMultiPolygon function takes a geometry as an input parameter and converts it to a multipolygon. The resulting multipolygon is represented in the spatial reference system of the specified geometry.

The specified geometry must be empty, a polygon, or a multipolygon. If the specified geometry is null, then null is returned.

## Syntax

## Parameter

- geometry
- A value of type ST_Geometry or one of its subtypes that represents
the geometry that is converted to a multipolygon.
A geometry can be converted to a multipolygon if it is empty, a polygon, or a multipolygon. If the conversion cannot be performed, then an exception condition is raised (SQLSTATE 38SUD).

## Return type

ST_MultiPolygon

## Example

In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display

This example
creates several geometries and then uses ST_ToMultiPolygon to return
multipolygons.

```
CREATE TABLE sample_geometries (id INTEGER, geometry ST_Geometry)
INSERT INTO sample_geometries
VALUES (1, ST_Geometry ('polygon ((0 0, 0 4, 5 4, 5 0, 0 0))', 1)),
(2, ST_Geometry ('point empty', 1)),
(3, ST_Geometry ('multipoint empty', 1))
```

In the following SELECT statement, the ST_ToMultiPolygon
function is used to return multipolygons converted to ST_MultiPolygon
from the static type of ST_Geometry. ```
SELECT CAST( ST_AsText( ST_ToMultiPolygon(geometry) )
AS VARCHAR(180) ) POLYGONS
FROM sample_geometries
```

Results: ```
POLYGONS
------------------------------------------------------------------------
MULTIPOLYGON (((0.000000000 0.000000000, 5.000000000 0.000000000,
5.000000000 4.000000000, 0.000000000 4.000000000,
0.000000000 0.000000000)))
MULTIPOLYGON EMPTY
MULTIPOLYGON EMPTY
```