With this simplified example (In reality I have thousands of points):

  geog geometry(GeometryCollection)

INSERT INTO test VALUES (ST_ConcaveHull('MULTIPOINT(-109 29, -110 28, 30 10, -109 29)',0.99));

I get the following error:

ERROR: Geometry type (Polygon) does not match column type (GeometryCollection)

How can I convert the Polygon type to a GeometryCollection type?

ST_Multi and ST_Collect only convert to MultiPolygon , not GeometryCollection.

  • Can you explain why you want to set geog to type GeometryCollection ? – pLumo Jan 26 '17 at 14:21
  • 2
    If you want a generic "can hold anything" geometry column, just omit the type modifier entirely. CREATE TABLE test (geom geometry) – Paul Ramsey Jan 26 '17 at 14:25
  • Indeed, it works without defining (GeometryCollection), I didn't know it was possible. What is the purpose of defining the type then? Some CONSTRAINT equivalent? – Victor Jan 26 '17 at 16:31

You can cast to GEOMETRYCOLLECTION using ST_ForceCollection http://postgis.net/docs/ST_Force_Collection.html

However, as suggested by Paul Ramsey, if you don't care about the type, you'd better drop the geometry type constraint from your geometry column.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.