Wednesday 20 February 2019

print composer - Creating a virtual layer based on a virtual field for dynamic selection in QGIS 3.4?


Working on a PostGIS database, I would like to send to the print composer the selected features only. I'v tried several methods including working with is_selected() expression but the only way that actually works is constructing a filter on the table based on a list of values from attribute data which is quite tiresome.



I'v been trying to work with a virtual layer which could be dynamically updated with selected features from my source layer and that I could send to the print composer. I first set a virtual field on my source layer with the expression is_selected which returns 1 when the feature is selected. Then, to build the virtual layer, I first embed my source layer and then use a query on it :


SELECT * from my_layer where "selected" = '1'

"Selected" being my virtual field which is updated each time I select a new set of features.


However, even if the virtual layer toolbox is telling me there are no errors, the created virtual layer stays empty even if I have some selected features and my virtual field is returning '1' value. There are no values shown in the attribute table and no geometry shown on map.


Maybe working with a virtual layer is not the way to do it and there is a simpler way, but I'v not found it yet.




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...