3

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?

  • I provided and answer but I realize this might be to much straightforward. Maybe edit your question to better describe what is your initial dataset and what you are actually trying to achieve. – MarHoff Oct 27 '15 at 9:16
2

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.

1

Thanks for your response.

Here is the sql, that will add new columns with "arcs" geometry to my existing tables - 'lines' and 'polygons':

ALTER TABLE lines ADD COLUMN the_geom geometry(CompoundCurve,2180);
ALTER TABLE polygons ADD COLUMN the_geom geometry(CurvePolygon,2180);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.