ST_ForceCollection

更新时间:
复制 MD 格式

Converts a geometry object into a GeometryCollection object, simplifying its Well-Known Binary (WKB) representation.

Syntax

geometry ST_ForceCollection(geometry geomA);

Parameters

ParameterDescription
geomAThe geometry object to convert.

Usage notes

  • Useful for simplifying the Well-Known Binary (WKB) representation.

  • Supports circular strings, curves, and polyhedral surfaces.

  • Supports 3D objects and preserves Z coordinates.

Examples

Convert a polygon to a GeometryCollection:

SELECT ST_AsText(ST_ForceCollection(ST_GeomFromText('POLYGON((1 1,2 1,2 2,1 2,1 1))')));

Output:

                     st_astext
----------------------------------------------------
 GEOMETRYCOLLECTION(POLYGON((1 1,2 1,2 2,1 2,1 1)))
(1 row)