1

I have a geometry column with mixed geometries like polygon, multi polygon. I am trying to set SRID for it using below query but I get the below error. What type of geometry has to be given when we have multi polygon and polygon type in one column?

Query:-

ALTER TABLE geo_table
ALTER COLUMN geom TYPE geometry(POLYGON,4326) USING ST_TRANSFORM(ST_SetSRID(geometry,3857),4326)

Error:-

ERROR:  Geometry type (MultiPolygon) does not match column type (Polygon)
3
  • 2
    I would force them to be all be multi using st_multi. then run your SRID command with multipolygon
    – ziggy
    Nov 9, 2022 at 17:39
  • 3
    Does this answer your question? Postgis change geometry type to Polygon
    – ziggy
    Nov 9, 2022 at 17:41
  • 1
    A generic geometry type "geometry" accepts all kind of geometries.
    – user30184
    Nov 9, 2022 at 17:58

1 Answer 1

2

you can use the generic geometry type. Also make sure to spell the proper column name in the using

ALTER TABLE geo_table
  ALTER COLUMN geom TYPE geometry(geometry,4326) 
    USING ST_TRANSFORM(ST_SetSRID(geom ,3857),4326);
0

Your Answer

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

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