[GIS] How to create a PostGIS table with arc support compatible with QGIS

geometrypostgisqgis

In postgis database I have two tables – let's say 'polygons' (gid, the_geom,MultiPolygon,srid=2180) and 'lines' (gid, the_geom,MultLineString,srid=2180). I'd like to use "Add circular string tool" from qgis to create same arcs and save in those layers. From web and from qgis error message (Geometry type (MultiSurface) does not match column type (MultiPolygon); Geometry type (MultiCurve) does not match column type (MultiLineString)
I know that I should have tables in postgis with geometry type MultiSurface and MultiCurve.

How should I do that? Can I have that kind of geometry type added respectively to my existing tables ie. MultiSurface to 'polygons' and MultiCurve to 'lines'? If anyone can give working solutions in sql code?

Best Answer

I don't use arcs for now but i do use table with multiples geometries so this might fit your need.

What you have to do is declare your table with unconstrained geometry type. But be warned because this imply that you actually know what your are doing because it will remove a 'stupid-proof' protection that can lead to unwanted behavior if not handled with care.

The way to declare an unconstrained column is to use this generic type modifier in the create statement

geom geometry(Geometry,2154) --The integer is just the target SRID

You can even drop the SRID altogether

geom geometry

But madness can ensue and some client application might not be able to use this table easily. (One of my main geographic table is declared so and is perfectly functional and optimized, but I cant emphasis too much on the 'handle with care' warning)


More specifically for QGIS you'll have to do a little set up for theses specific layer to show up in the list. You must modify the Postgis connection as follow. Side effect be slow loading if you have huge unconstrained geom column.

enter image description here

And finally please notice that you'll have to open each data-type as a separate layer in QGIS when you add them. So i cant' predict if the specific tool you mentioned will work but if the error message come from database it might. If the error message come from QGIS or the tool it might not.

Related Question