I have a project file with many nested layers and would like to query certain layers without having to click on them first. The expression tool however requires me to select the layer I want to query. Is there a way to do an expression like SELECT FROM "Layername"='Cities' WHERE "CITY"='New York' AND "Pollution" = 'low'?

I dug around a bit and only found the Expressions+ plugin but that didn't help either.

Edit for clarification: I do not want to filter any layers. I want to access data from any layer from anywhere with a query without having to select it from the layer stack first.

Let's say I have the layer "Fields" activated and press the expression button. The current option is that I can use expressions to query the "Fields" layer's data. However I want to look for data from another layer, e.g. "Cities".

I'm looking for a solution that lets me use the current expression tool. I have come up with an idea to solve the problem with python (save current layer name, navigate to layer x, then use the query window, then go back) but before I write that up I wanted to see if there's already something useful (and more elegant).

  • You probably could achieve this using PyQGIS, are you open to a PyQGIS-based solution? – Germán Carrillo Mar 1 '15 at 12:24
  • Edited my question. Generally yes, if there are no other options. – MapEngine Mar 1 '15 at 12:46
  • Ok, let's wait for something "more elegant" than a PyQGIS script. – Germán Carrillo Mar 1 '15 at 13:11
  • The elegance remark was targeted at my solution concept, not scripting itself. I don't know if switching around in the layers is the best solution. – MapEngine Mar 1 '15 at 13:18

Your Answer

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

Browse other questions tagged or ask your own question.