0

With QGIS 2.14.3 I am attempting to convert a raster layer to a binary layer, using a certain threshold. With some layers I can use this formula in the Raster Calculator and get the expected output;

"raster@1" < 0.994 = 0 AND "raster@1" > 0.994 = 1

But when I try it with another layer the output is either all nan or all 0's. I've tried saving it in a different format (.img instead of .tif) as suggested in another answer here, but get the same result.

Is there a mistake I'm making with this?

Or an obvious reason it might give this output?

Or maybe the raster is just corrupted in some way?

(The imagery is the output from a long process, and confidential, so I can't share the actual file).

  • Could you try "raster@1" >= 0.994? Actually this should procure the same output. – Erik Sep 24 '18 at 9:04
1

You are asking an impossible question, raster@1 cannot be less than 0.994 AND greater than 0.994 at the same time. I would change it to

"raster@1" < 0.994 = 0 OR "raster@1" >= 0.994 = 1
  • Perhaps I misunderstand how the Raster Calculator works? Cells within the raster can have values of less than and greater than 0.994. I have used the formula as written above with AND, which gave the expected output. – EcologyTom Sep 24 '18 at 14:33

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.