[GIS] Postgresql table won’t display in QGIS 2.2

postgispostgresqlqgis

I just downloaded QGIS 2.2 to check it out and now one (just the one) of the tables from one of my PostgreSQL database won't display.

It loads just fine in 2.0. The records are all there (there's only 3 in this case), I can see them in the attribute table, I can query them, but they don't show up on the map.

When I try to zoom to a particular feature it pans the map down to the origin of the datum (coordinates 0,0) – but when I zoom to the extent of the layer it sets the map back to where it is supposed to be.

What am I missing in the jump from 2.0 to 2.2?

Best Answer

I noticed the same behavior. Upon further investigation, it was only tables with 4d dimensions (In my case MultiPolygonZM) that wouldn't display in QGIS 2.2. I didn't test 3dm or 3dz as I don't have any data handy. You can check the coord_dimension column of your geometry_columns view.

If the Z/M coordinates are not important, you can ditch them like this:

ALTER TABLE schema.table ALTER COLUMN geom TYPE geometry(MULTIPOLYGON,4326) USING ST_Force2d(geom);

Or create a view of the table with 2d coordinates for display purposes using ST_Force2d.

If you have many tables to fix, I wrote a quick python loop to take care of the problem: https://gist.github.com/guitar1999/9442467

Related Question