3

Aim: i would like to create a model that allows my user to select records from a table between two years. Methodology: i am using modeler in QGIS LTR 2.14.9 (win is the OS of my PC) table A is a vector file (point), select by expression is the algorithm which should run the following expression: "date" >= start_year AND "date" <= end_year where start and end year are two numbers.

I try to add to the model two parameters (numbers) called start_year and end_year with a min/max values 1800/2050

I would like to see these two parameters taken as input in the expression i wrote in the select by expression algorithm but i am not successful. I have checked on StackExchange and i came across this previous post:

How to multiply a user-defined input parameter with a field value within the graphical modeler?

Is creating a script still the only solution or there is another one for people without coding experience?

1

This is not an answer to my question but something i worked out, it is not the most elegant solution but it is working now. However, i am still looking for an answer to my original post.

The way i sorted my problem out is the following: i added a select by attribute algorithm which takes as input the vector file and as value the start_year (string). the algorithm performs the following date >= start_year. Then i added a second select by attribute algorithm and this time the input is the previous selection and the parameter is end_year. The algorithm performs date <= end_year. NOTICE: it is important to save the first selection (date <= start_year) and then use this output as input for the second select by attribute algorithm. Otherwise the final result is wrong. I have tested again as i had noticed problems. The model looks like in the picture in attachment

enter image description here

As said, it is not elegant but it works. I am still interested in knowing if, a part from a script, there is another way to answer the original question i posed.

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.