Is there any way to typecast Polygons to Multipolygon type?

For example, I have created a circle using ST_Buffer() on a point. The return type of that function is of Polygon type. The problem is that on the geometry column there is a restriction limiting it to Multipolygon type. So, I cannot insert a simple polygon.

I have used ST_MPolyFromText() function, but as usual it is returning null for that and ST_Dump() is not giving the proper output.

The constraint is:

CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'MULTIPOLYGON'::text OR geom IS NULL),
  • Is there a reason for adding a multipolygon constraint? How about changing the constraint to polygon?
    – underdark
    Sep 1, 2011 at 7:24
  • Isnt't this a children question of gis.stackexchange.com/questions/14198/… ?
    – unicoletti
    Sep 1, 2011 at 7:36
  • It is, but it could be rephrased to be a stand-alone question too.
    – underdark
    Sep 1, 2011 at 8:02
  • yes this is a children question,, but the problem is when you import the shapefile into the postgis which is containing the polygon layer then automatically it creates the geometry of multipolygon. then it is little bit tedious to convert the datatype from multipolygon to polygon.. because that will be done by the client . So just have to save the output into that colummn of that type created by the postgis..
    – Vicky
    Sep 1, 2011 at 13:12
  • PS: to do the inverse, from multi-to-poly, use st_geometryn(geom, 1). Jan 13, 2014 at 12:23

1 Answer 1


ST_Multi - Returns the geometry as a MULTI* geometry. If the geometry is already a MULTI*, it is returned unchanged.


SELECT ST_AsText(ST_Multi(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
        743265 2967450,743265.625 2967416,743238 2967416))')));
        MULTIPOLYGON(((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,
        743238 2967416)))
        (1 row)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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