TransWikia.com

Export MultiPolygon from MultiSurface layer in QGIS

Geographic Information Systems Asked on May 2, 2021

I have a layer in QGIS that is a Multisurface layer currently stored on a PostGIS server I want to add this layer as a MultiPolygon layer to PostGIS using QGIS.

Can I specify this somehow when I save/export to QGIS? The only workaround I found is exporting the layer to a shape file loading it and exporting it then to PostGIS.

One Answer

  • within PostGIS:
    CREATE TABLE <multipolygon_layer> AS
      SELECT <id>,
             ...,
             ST_CurveToLine(<geom>) AS <geom>
      FROM   <multisurface_layer>
    ;
    
  • using ogr2ogr (GDAL > 3.0.5):
    ogr2ogr -f PostgreSQL <pg_conn> -nln <multipolygon_layer_name> -nlt CONVERT_TO_LINEAR -nlt PROMOTE_TO_MULTI <source>
    
    or, if the approximated linear geometries will always be areal, simply
    ogr2ogr -f PostgreSQL <pg_conn> -nln <multipolygon_layer_name> -nlt MULTIPOLYGON <source>
    

Correct answer by geozelot on May 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP