PostGISGeometry Accessors

ST_IsCollection

What is ST_IsCollection?

ST_IsCollection is a PostGIS function that returns true if the geometry is a collection type — MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, or GEOMETRYCOLLECTION — regardless of how many components it contains. A multi-geometry with a single component still returns true.

SQL
ST_IsCollection(geometry g)boolean

Faster and more reliable than string comparisons on GeometryType for this specific check.

When would you use ST_IsCollection?

Use ST_IsCollection when your pipeline handles simple and multi geometries differently — for example to unpack multis with ST_Dump before per-part operations, or to enforce schema constraints that forbid collections:

SQL
1SELECT id, geom
2FROM imports
3WHERE ST_IsCollection(geom);   -- flag multi for normalization

Note that "collection" here is a container test, not a count test — MULTIPOINT(1 2) with one point is still a collection.

FAQs

Does ST_IsCollection distinguish between Multi* and GeometryCollection?

No. Both return true. Use GeometryType or ST_GeometryType when you need to know which.

What about a MultiPolygon with one polygon?

Still true. The type is what determines the result, not the component count.

Is ST_IsCollection index-friendly?

No — it is a metadata function without spatial-index acceleration. Use sparingly in WHERE on very large tables, or precompute a boolean column.

How do I convert a one-component multi back to single?

Use ST_GeometryN(geom, 1) to pull out the single component, or ST_CollectionExtract to extract components of a specific type.