I want to create a Postgresql view using point data. When I create the view, the geometry_columns table updates appropriately. Attempting to load in QGIS produces the error “(the_geom) sql = is an invalid layer and cannot be loaded”.

For all of the working (polygon) views, when I load them in QGIS, I need to specify the primary key column (as documented here: How to make a spatial view in PostGIS and add it as a layer in QGIS?). When I try to add my point view, I am not given the option to choose the primary key.

I have tried several tables all with Point geometry and nothing is working. The tables do have the 3 constraints: enforce_dims_the_geom, enforce_geotype_the_geom, and enforce_srid_the_geom. I have also run st_isvalidreason (the_geom) and the geometry is valid. How do I get a view with point data to show the selection for a primary key in QGIS?

We are running PostGIS 1.4 and I am using QGIS 1.8.


1 Answer 1


Once you connect to the PostGIS db and a window appears with the list of available tables, if you scroll over to the right, there should be a column "Primary Key". For tables where QGIS doesn't recognize the PK, there should be a drop down so you can choose which column is the PK. If you have a column in the database table called "gid" which is a PK, then this should work without any need to manually choose the column.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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