O'Reilly logo

QGIS By Example by Daria Svidzinska, Alexander Bruy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing feature selection

Now, when dialogs are created and connected to our plugin, we can start implementing the main functionality—namely, feature selection using requirements defined by the user.

Open the selectradiusdialog.py file located in the gui subdirectory of the plugin source tree. Add the following code at the end of the accept() method:

( 1) self.btnOk.setEnabled(False) ( 2) self.btnClose.setEnabled(False) ( 3) ( 4) request = QgsFeatureRequest() ( 5) request.setFlags( ( 6) request.flags() ^ QgsFeatureRequest.SubsetOfAttributes) ( 7) ( 8) index = QgsSpatialIndex(targetLayer.getFeatures(request)) ( 9) (10) selection = [] (11) for f in referenceFeatures: (12) geom = QgsGeometry(f.geometry()) (13) bufferedGeometry = geom.buffer(self.spnRadius.value(), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required