<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default">Hi</div><div class="gmail_default">I'm trying to label each TopoGeom in a layer with it's id using 'id(<TopoGeom column name>)'. </div><div class="gmail_default"><br></div><div class="gmail_default" style="font-family:Arial,Helvetica,sans-serif"><span style="font-family:"courier new",monospace">sql = "SELECT *, id(my_topo_column) geom_id FROM myschema.mytable"</span></div><div class="gmail_default" style="font-family:Arial,Helvetica,sans-serif"><font face="courier new, monospace">my_uri.setDataSource('', '({})'.format(sql), 'topo', '', 'geom_id')<br></font><span style="font-family:"courier new",monospace">my_uri</span><font face="courier new, monospace">.setSrid(str(my_layer_srid))<br></font><span style="font-family:"courier new",monospace">my_uri</span><font face="courier new, monospace">.setWkbType(my_layer_type)<br>my_layer = QgsVectorLayer(</font> <span style="font-family:"courier new",monospace">my_uri</span><font face="courier new, monospace">.uri(False), my_layer_name, 'postgres')</font><br></div><div class="gmail_default" style="font-family:Arial,Helvetica,sans-serif"><font face="courier new, monospace"><br></font></div><div class="gmail_default" style="font-family:Arial,Helvetica,sans-serif"><font face="arial, sans-serif">This gives the following warning</font></div><div class="gmail_default" style="font-family:Arial,Helvetica,sans-serif"><font face="arial, sans-serif"><br></font></div><div class="gmail_default" style="font-family:Arial,Helvetica,sans-serif"><p style="margin:0px;white-space:pre-wrap"><font face="courier new, monospace"><span style="color:rgb(220,125,0)">WARNING    </span>Could not find topology of layer NULL.NULL.'topo'</font></p><p style="margin:0px;white-space:pre-wrap"><font face="courier new, monospace"><br></font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif">Just adding the layer works. My guess is that since this sets the schema and table names the provider is able to pick them up when it tries to find the topology. I tried to supply a schema name but that crashes QGIS. I guess the table declaration as a SELECT query doesnä't have a table name.</font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif"><br></font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif">I tried to add a layer manually throught the DB Manager SQL Window with the same result and warning.</font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif"><br></font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif">Are there any special considerations that I've missed when trying to add TopoGeom layers using PyQGIS?</font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif"><br></font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif">Regards</font></p><p style="margin:0px;white-space:pre-wrap"><font face="arial, sans-serif">David</font></p></div></div></div>