1

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?

1

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.

1
  • Thank you Matthias Kuhn. Finnally I have got I wanted "playing" with selection and zoom Sep 29 '15 at 21:25
0

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):

self.vlayer.selectAll()
extent = self.vlayer.extent()
self.iface.mapCanvas().setExtent(extent)
self.vlayer.removeSelection()

Your Answer

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

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