1

My select feature is acting weird. I am making a plugin that downloads an WFS layer and then filter out objects based on the features. But when i try to select the points by an area, the points that are selected seems very random. It appears that no matter where i make the selection, the the same points are selected. If I select two points, it's always the same two, if i select ten points, it's always the same ten.

I get the layer by this method:

        QgsMapLayerRegistry.instance().addMapLayer(WFSlayer)
        self.hideLayer(WFSlayer)
        self.iface.legendInterface().setLayerVisible(WFSlayer, False)
        layer_name = self.WFSlayer.name()
        query = "SELECT * FROM " + layer_name + " " + where #where statement created elswhere
        vLayer = QgsVectorLayer("?query=%s" % (query), "newLayer", "virtual" )
        QgsMapLayerRegistry.instance().addMapLayer(vLayer)
        self.canvas.setExtent(vLayer)

I have another method of adding layer in memory insetad, and this layer does not have the same problem.

I have no idea why this particular layer acts like this, while all others acts normally.

Area that is being selected: Area that are beein selected

The obects that gets selected The objectes that are selected

  • I wonder if this issue is related to the bug described in this post for selecting features in a vitual layer (although the bug should have been fixed). Which QGIS version and for which platform are you using? – Joseph Nov 13 '17 at 12:45
  • @Joseph It seems like it might be related. I am using QGIS 2.18.13 on Windows 10. I see that 2.18.14 is available. I can see if i get the same problem with that version. – Kasper Skjeggestad Nov 13 '17 at 13:09
  • I too am using QGIS 2.18.13 but for Windows 7 64-bit. Not sure if its an issue with operating system though. Also, your query seems incomplete :) – Joseph Nov 13 '17 at 13:13
  • @Joseph, Oh, it is. I have been trying with a compleat query however, and now with 2.18.14, same results. I turned off my plugin in and tryed to create the layer from a WFS layer like this: vLayer = QgsVectorLayer("?query=SELECT * FROM TettstedInngangBygg", "VirtualLayer", "virtual" ) QgsMapLayerRegistry.instance().addMapLayer(vLayer) to see if there was anything in my plugin, but this gave the same results – Kasper Skjeggestad Nov 13 '17 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.