# Numpy Logical Syntax in QGIS GDAL Raster Calculator

I need to set a logical expression in the box of the GDAL's Raster Calculator using Numpy. My knowledge in Numpy and python is extremely limited (I'm not a Developer just a simple Geographer!). I've seen on this post (Using variable in graphical modeler for raster calculation? (QGIS 3.8)) an example of how to append 2 parts in that box, the part using the letters (A, B, C...) and the other from other inputs like numbers. In that example is easy ('a + ' || @numberinput). My question is about logical statements. I tried 'a >=' || @numberinput and the result is wrong. I checked the numpy documentation and all is about arrays which is notice is kind of complex, I don't need to do too much, just get those A values less or greater than the result from a formula expressed as string getting one variable number from the @numberinput. I'm attaching the images of what I'm doing for you to help me. Threshold set using String concatenation, the output will be used in GDAL Raster Calculator

Then inside GDAL Raster Calculator you can see my issue:

Finally, you can see what I'm trying to do inside the Expression window.

I think this is an easy question for python experts.

• Seems like you are sending the `'A < ((-25) * @DayOfYear) + 7225 + 0'` string to the calculator, when it must be `'A < ((-25) *' || @DayOfYear || ') + 7225 + 0'`. Maybe you can do it improving the string concatenation, I don't know if you can put the ' symbol inside the string to concatenate, like `((-25) *' || @DayOfYear || ') + 7225` instead of `((-25) * @DayOfYear) + 7225`. Commented Aug 21, 2020 at 10:11
• Also, I think that you need to enclose the computed value to be compared to A: `'A < (' || @HighThreshold_CONCATENATION || ')'`. Do not worry about numpy, this is a strings concatenation question. Commented Aug 21, 2020 at 10:20
• The first expression I think is not necessary because I need to get 2 different outputs from @DayOfYear (the 0+ was just a trick to cheat the String concatenation tool). If there was a way to write a complete expression including the String concatenation formula + the raster calculator ranges for HighThreshold and LowThreshold, it would be even better, specially for memory issues. I've tried your string for the computed value and the result is still wrong. Commented Aug 21, 2020 at 16:26