Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QGIS edit turning POLYGON into MULTISURFACE

Tags:

postgis

qgis

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?

like image 268
Derek Avatar asked Oct 24 '25 14:10

Derek


1 Answers

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.

like image 77
DPSSpatial Avatar answered Oct 26 '25 04:10

DPSSpatial