I have made a plugin for QGIS in pyQt. Then I can make a query from a PostGIS database and I get the plot or bunch or plots results of that query in a layer. This layer is overlapped on the top of a layer who show all the plots. But sometimes I get only one of two plots, and they "lose" between more than 5000 plots, then I would like to put the plot or bunch of plots in a frame.

Any idea how could I do that?

2 Answers 2


If you want to put a frame around the plots, you could use the generated layer's extent and highlight it with a QgsRubberband.

Instead, you could also explore the possibility to adjust the generated layer's style to be more prominent than the baselayer's style. E.g. you could use a border with a width in pixels and a prominent color so it will stand out especially at small scales. This approach can also be combined with a rule-based style which can increase visibility of the selected plots at small scales and decrease (e.g. with reduced saturation) the visibility of the base map.

  • Thank you Matthias Kuhn. Finnally I have got I wanted "playing" with selection and zoom
    – exodehm
    Sep 29, 2015 at 21:25

Well, the best solution for me has been to select all the plots of the new generated layer. Then, zoom to extent, and finnally, unselect the plots.

This is the snippet of the code (with self.vlayer as resulting layer of my query):

extent = self.vlayer.extent()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.