<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Your view needs a primary key to work.<br><br>your gid value provides this in the table, but QGIS may not be picking this up in the view?<br><br>Does this help?<br><br><a href="http://gis.stackexchange.com/questions/25699/how-to-make-a-spatial-view-in-postgis-and-add-it-as-a-layer-in-qgis">http://gis.stackexchange.com/questions/25699/how-to-make-a-spatial-view-in-postgis-and-add-it-as-a-layer-in-qgis</a><br><br>Brent Wood<br><br>--- On <b>Mon, 2/18/13, Andrea Peri <i><aperi2007@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Andrea Peri <aperi2007@gmail.com><br>Subject: [postgis-users] How create a polygon rectangular from the BBOX of a geometry.<br>To: "PostGIS Users Discussion" <postgis-users@postgis.refractions.net><br>Date: Monday, February 18, 2013,
 4:06 AM<br><br><div class="plainMail">Hi,<br><br>I have a table named "route_streets" with a linear geometry in the epsg:3003.<br><br>I try to create a view (v_route_streets)  that has as geometry a<br>polygon with the BBOX of the linear geometry.<br><br>To do this I try this sql:<br><br>  create view streets.v_route_streets as<br>    select a.gid, a.ri05_name as name,<br>ST_Extent(a.geometry)::geometry(POLYGON, 3003) as geometry from<br>streets.route_streets as a group by a.gid,a.ri05_nome;<br><br>It is normally created but when try to use it on qgis I'm hhaving an error.<br>QGIS say that this is not a valid layer.<br><br>I don't understand where is the problem.<br><br>I'm using postgis 2.0.1<br><br>Any hint is welcome,<br><br>thx,<br><br><br>-- <br>-----------------<br>Andrea Peri<br>. . . . . . . . .<br>qwerty אטלעש<br>-----------------<br>_______________________________________________<br>postgis-users mailing list<br><a
 ymailto="mailto:postgis-users@lists.osgeo.org" href="/mc/compose?to=postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></div></blockquote></td></tr></table>