Saturday, 7 February 2015

How to select and zoom in features from a QGIS Python Plugin


I'm very new to Python. I'm trying to find a way to select and zoom to the features from a QGIS layer.


I've created a plugin and built a custom form. I have 3 values from the form which I need to place in a query but as I'm new, I don't know how.


aExchange = self.dlg.EXCHANGE_1141_CODE.currentText()
aPCP = self.dlg.BT_OBJECT_CLASS.currentText()
aObject = self.dlg.BT_OBJECT_ID.text()

The filter on the Attribute table is like this:



"EXCHANGE_1141_CODE" = 'IH' AND "BT_OBJECT_CLASS" = 'PCP' AND "BT_OBJECT_ID" = '10' 

I've tried:


alayer.SetSubSetString ('EXCHANGE_1141_CODE = \'IH\'') 

but this seems to just change the filter on the layer source which isn't what I want.


I want to be able to search for a feature and go to it. How can I do it with PyQGIS?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...