How to make a spatial view in PostGIS and add it as a layer in QGIS?

المشرف العام

Administrator
طاقم الإدارة
In PostGIS 2.0, what is the most efficient way to create a spatially enabled view that is viewable in QGIS?

I followed the context of Part 2 of @Mike Toews answer to this question, and the view shows up as a point layer (in my case) in the "Add PostGIS Layers" dialog. But after creating the view and spatially enabling it, I received the following error when trying to add the view to QGIS:

You must select a table in order to add a layer

Can someone please explain why the spatial view will not load into QGIS, and what I need to do in order to make it loadable as a layer in QGIS?

UPDATE 1:(I'm currently using QGIS v1.8 from the OSGEO installer)

I view is built from the geonames database, loaded into PostGIS. The geoname table/spatial data can be selected/viewed in QGIS just fine.

When I try to select the "mt_view", QGIS sees the view in the dialog, but won't let me select it. It gives a dotted box around the area, but does not highlight and select the view.



UPDATE 2:I just noticed that when I run my first query:

CREATE OR REPLACE VIEW data.test ASSELECT * FROM data.geonameWHERE admin1='MT'the view shows up in the QGIS Add Layer Dialog, but is unselectable. Then when I run:

SELECT Populate_Geometry_Columns('data.test'::regclass);I get the result of "0", where according to the documentation, I think it should be returning "1". Any thoughts?



أكثر...
 
أعلى