3

I am trying to use the raster calculator in QGIS to filter out depths lower than 0.01cm (in geotif which represent a flood map, respectively the depths), while keeping the original values of the raster. When I use the syntax I always get output with 0s and 1s, or I get the raster ranging from 0 up to max, where 0s represents the values below 0.01,and I am trying to avoid that. I am trying to get raster with values ranging from 0.01 up to max.

("HQ100_2D_PD@1" >= 0.01) * "HQ100_2D_PD@1"

I know that vectorizing the raster to points, then filtering out the values in attribute table will definitely work but I am looking for more elegant and faster approach using Raster Calculator.

Any ideas?

6
  • Why are you reposting your question?
    – Erik
    Commented Mar 20, 2020 at 9:02
  • @Erik it was closed but without any answer, I do not understand why it was closed. Thats why I reposted the question because from my point of view there were not any reactions except edits of text.
    – Petr
    Commented Mar 20, 2020 at 9:56
  • @BERA I can, which way of transfer suits you the best?
    – Petr
    Commented Mar 20, 2020 at 9:57
  • @Petr there always is a reason why a question was closed, which you usually can remedy by editing the question properly. Please refrain from spamming your question if you get no answer in the future.
    – Erik
    Commented Mar 20, 2020 at 10:07
  • I deleted the previous one so not to spam. However, I dont see your point, it does not make sence. How can you close a question which was just posted? But thats different duscussion, if you can help with this matter its welcomed and well apreciated.
    – Petr
    Commented Mar 20, 2020 at 10:35

2 Answers 2

3

This expression should set values below 0.01 to NA, and retain the values including and above 0.01: "HQ100_2D_PD@1"/("HQ100_2D_PD@1">=0.01)

1
  • Thank you, that works great.
    – Petr
    Commented Mar 21, 2020 at 8:08
1

With your expression, you get values from 0.01 to max, and zeros.

You can assign 0 values to nodata in the raster layer.

Or you can define another value or expression to the pixels that not satisfy the condition:

The condition will return a 0 if false. If you don't want zeros, you can include another mutually exclusive condition to be true when the first one is false, and an operation for the true condition.

The following expression will set all pixels below 0.01, to 0.01:

("HQ100_2D_PD@1" >= 0.01) * "HQ100_2D_PD@1" + ("HQ100_2D_PD@1" < 0.01) * 0.01
1
  • Thank you for suggestion, how the answer above is what I was looking for, I wanted to exclude all values lower than 0,01 from the raster.
    – Petr
    Commented Mar 21, 2020 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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