Is there a PostGIS function that can change geometry type for an existing table?
We need to change from POINT to MULTIPOINT.
The table will be empty when we change the geometry type and we cannot just drop/create the table.
|
Is there a PostGIS function that can change geometry type for an existing table? We need to change from POINT to MULTIPOINT. The table will be empty when we change the geometry type and we cannot just drop/create the table. |
||||
|
|
|
For PostGIS 2.x, you can use the ALTER TABLE DDL using an expression. To convert from a single-part to multi-part geometry, use ST_Multi:
To convert from a multi-part to a single-part geometry, it is a bit more tricky since you can only use one part, and ignore all other parts (if they exist). Check your data first to see if you have some geometries with more than one part:
If you see
For PostGIS 1.x, it is a bit more messy, as there are several steps (thanks @rec.thegeom!). Assuming a table
|
|||||
|
|
Change, I don't think so. But you can create a new table with identical structure, except for the geom column, then run:
|
|||
|
|