> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GEOMETRYCOLLECTION

A `GEOMETRYCOLLECTION` is a collection of heterogeneous [spatial objects](https://docs.cockroachlabs.com/docs/v24.2/spatial-data-overview#spatial-objects), such as [Points](https://docs.cockroachlabs.com/docs/v24.2/point), [LineStrings](https://docs.cockroachlabs.com/docs/v24.2/linestring), [Polygons](https://docs.cockroachlabs.com/docs/v24.2/polygon), or other `GEOMETRYCOLLECTION`s.  It provides a way of referring to a group of spatial objects as one "thing" so that you can operate on it/them more conveniently using various SQL functions.

You can also store a \`\` with the following additional dimensions:

* A third dimension coordinate `Z` (`Z`).
* A measure coordinate `M` (`M`).
* Both a third dimension and a measure coordinate (`ZM`).

The `Z` and `M` dimensions can be accessed or modified using a number of [built-in functions](https://docs.cockroachlabs.com/docs/v24.2/functions-and-operators#spatial-functions), including:

* `ST_Z`
* `ST_M`
* `ST_Affine`
* `ST_Zmflag`
* `ST_MakePoint`
* `ST_MakePointM`
* `ST_Force3D`
* `ST_Force3DZ`
* `ST_Force3DM`
* `ST_Force4D`
* `ST_Snap`
* `ST_SnapToGrid`
* `ST_RotateZ`
* `ST_AddMeasure`

Note that CockroachDB's [spatial indexing](https://docs.cockroachlabs.com/docs/v24.2/spatial-indexes) is still based on the 2D coordinate system.  This means that:

* The Z/M dimension is not index accelerated when using spatial predicates.
* Some spatial functions ignore the Z/M dimension, with transformations discarding the Z/M value.

## Examples

A GeometryCollection can be created from SQL by calling the `st_geomfromtext` function on a GeometryCollection definition expressed in the [Well Known Text (WKT)](https://docs.cockroachlabs.com/docs/v24.2/architecture/glossary#wkt) format as shown below.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0, 1440 900), POLYGON((0 0, 0 1024, 1024 1024, 1024 0, 0 0)))');
```

```
                                                                                                                                                              st_geomfromtext
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  0107000000030000000101000000000000000000000000000000000000000102000000020000000000000000000000000000000000000000000000008096400000000000208C40010300000001000000050000000000000000000000000000000000000000000000000000000000000000009040000000000000904000000000000090400000000000009040000000000000000000000000000000000000000000000000
(1 row)
```

## See also

* [Spatial tutorial](https://docs.cockroachlabs.com/docs/v24.2/spatial-tutorial)
* [Spatial objects](https://docs.cockroachlabs.com/docs/v24.2/spatial-data-overview#spatial-objects)
* [POINT](https://docs.cockroachlabs.com/docs/v24.2/point)
* [LINESTRING](https://docs.cockroachlabs.com/docs/v24.2/linestring)
* [POLYGON](https://docs.cockroachlabs.com/docs/v24.2/polygon)
* [MULTIPOINT](https://docs.cockroachlabs.com/docs/v24.2/multipoint)
* [MULTILINESTRING](https://docs.cockroachlabs.com/docs/v24.2/multilinestring)
* [MULTIPOLYGON](https://docs.cockroachlabs.com/docs/v24.2/multipolygon)
* [Using GeoServer with CockroachDB](https://docs.cockroachlabs.com/docs/v24.2/geoserver)
