4

I have a PostGIS table with POLYGONs that I need to do some cleanup editing on in QGIS. However even a simple edit like deleting a vertex is saving the result back as a MULTISURFACE.

I am using QGIS 3.16.

How do I instruct QGIS to use the simplest geometry type that can represent the edited polygon?

Derek
  • 345
  • 3
  • 15

1 Answers1

2

I think what is happening is geom columns that are generic "geometry" types are forcing QGIS to guess and/or convert the edited geometry in these columns to multisurface - I don't know why.

To get around this, I created a new column and set the type explicitly to multipolygon type:

alter table schema.table_name
add geom_mult geometry (Multipolygon, 4326); 

Then transfer my old geom column of 'mixed' geometries into this new column using ST_Multi(geom) to convert them:

update 
schema.table_name
set geom_mult = ST_Multi(geom); 

From there, I went back into QGIS and added the new table_name.geom_mult to my project. I went through the exact same editing scenarios that were causing the conversion to multisurface, and it is not converting them anymore - the polygons are all staying multipolygon - this includes topological editing using 'reshape surface' tasks and creating new singlepart polygons (qgis/postgis is storing them automatically as multipart).

So now I'm going to drop my old geom column, create a new one of multipolygon type, and re-add my converted multipolygons to this new column using an UPDATE.

All my applications that expect a column called geom work just fine. I can change my QGIS layer definition to use MultiPolygon instead of Polygon.

Also I'm doing all this using multipolygon instead of just polygon as I do indeed have multipolygon data in my table, in addition to singlepart polygons. No one (QGIS, PostGIS) seems to care if singlepart polygons are stored as multipart features that I can tell.

DPSSpatial
  • 767
  • 3
  • 11
  • 31
  • Finally able to go back and test this - the issue I was having (that I wanted to figure out) was that the ST_Dump step I had in there was not only unnecessary but it was dropping parts of my multipolygons. The above correction seems to work just fine... let me know if you are able to use it! – DPSSpatial Aug 10 '23 at 21:27