0

I would like to calculate a simple range using the QGIS 2.0 Raster Calculator, but am getting strange results. I believe I am not using the correct syntax.

To get all values between .003-.5, I entered the following: enter image description here

This resulted in the following raster:

enter image description here

As I found this result very strange, I decided to check all values above .003: enter image description here

This resulted in the following raster, which I believed to make sense. It is simply the inverse of the first without any overlap, meaning I am unable to target all values within my needed range: enter image description here

When attempting with AND logic, I got a completely black raster image: enter image description here

Now, I've tried to fix the issue by separating the categories completely. The raster is still black. enter image description here

Elevation greater than 5: enter image description here

Elevation greater than .03. Note, that I happened to test .03 instead of .003 in this case as opposed to previous screen captures: enter image description here

I'm just looking to have the elevation between these two values.

  • What if you put your two expressions in parentheses - (> .003) AND (< .5)? Or use a leading 0 before your decimal? And I'm assuming it's verified there are values in that range in the raster. I also can't tell if the quotes are needed around the raster name - the documentation seems to contradict itself (screenshot vs code formatted expression examples), and other examples I see don't use them. – Chris W Jul 18 '14 at 2:34
  • @ChrisW Yes, the values are confirmed using another software. Adding the parenthesis in this way is considered "invalid" by qgis. – user25976 Jul 18 '14 at 8:20
  • You definitely need to split the two arguments with a logic operator - that much I'm sure on. But the more documenation I look at, the more confused I get about the remaining syntax. Can you try (taharuu_GRASSrst@1 < 0.003) OR (taharuu_GRASSrst@1 > 0.5) = 0 and see if that works? Then add quotes around the raster name if it doesn't? And if that still doesn't work, I'm out of ideas. – Chris W Jul 18 '14 at 20:14
  • @ChrisW I wish that worked too. I'm very puzzled... – user25976 Jul 19 '14 at 18:58
  • Sorry I can't be of more assistance. My suggestion was based on a blog post I'd found. I also noted a potential alternative approach in the QGIS training manual at the bottom of section 16.10 using an IF statement. Your results so far suggest to me there are no values in that range, but you've verified that already so I can't think of anything else aside from posting the raster for people to test with if you can. – Chris W Jul 19 '14 at 19:20
2

You are getting expected results with the "taharuu_grass_rst@1" >0.003 and "taharuu_grass_rst@1"< 0.5 expression. You are using boolean operators, so getting boolean results, (i.e. 1 & 0). To actually extract the values in that range, multiply by the original raster band.

("taharuu_grass_rst@1" >0.003 and "taharuu_grass_rst@1"< 0.5) * "taharuu_grass_rst@1"
0

Your expression should be

"taharuu_grass_rst@1" >=0.003 and "taharuu_grass_rst@1"<= 0.5
  • I just tried that and it still gives me a black screen. Are you trying to point out the leading zero, the minuscule "and" or the >= vs >? If it's the last, then I'm wondering how i'll be able to set the ranges correctly without overlap. – user25976 Jul 18 '14 at 6:04
  • The important part is splitting it into two separate criteria, joined with an "and". Can you post your updated expression? – ndawson Jul 18 '14 at 7:39
  • i've now added a screen capture with the separate categories. could > .003 and <= .5 technically work? – user25976 Jul 18 '14 at 8:23

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.