[GIS] PostGIS ST_Intersects GeometryCollection

postgisst-intersects

If i'm not terribly mistaken, ST_Intersects does not support GeometryCollection.

ERROR:  Relate Operation called with a LWGEOMCOLLECTION type.  This is unsupported.
HINT:  Change argument 2: 'GEOMETRYCOLLECTION(POLYGON((.......

Currently i am using a wrapper that cycles through the different types in a GeometryCollection and performing a ST_Intersect on each. Needless to say, this is terribly inneficient.

There must be a better way?

Best Answer

Spatial relation operators do not work on geometry collections by design, as inherited from JTS.

Try using ST_CollectionHomogenize, which will return a regular geometry, if possible. Or ST_CollectionExtract to specify a geometry type.

Related Question