3

I am doing the infamous qgistutorials:

  • Two raster layers (converted from vector to raster) having ("pseudo") band values 0 and 1, were added up with + in the raster calculator.

    This resulted in a "merged raster" with values 0, 1, 2; with 2 being the cross section of two 1s of the input rasters.

  • To remove the 2, the merged raster was put into the raster calculator. again with the expression merged raster > 0.

    As a result the latest raster has only 0, 1, (and the cross-section 2 was not represented in the raster image anymore).

Here is, where I have problems with comprehension. What does the calculator do in the last step?

I know that > is a bigger sign. But would not it take all the values from the raster > 0, i.e. take 1 and 2 and remove 0 information?

5

When your merged raster is composed of values 2, 1, 0, an expression merged raster > 0 will ask each cell if it is greather than zero. And the answers (Yes or No) will be returned as (1 or 0), which is usually referred as (True or False).

enter image description here

All the values greather than zero is converted into 1 (True), while zero is retained. The meaning of 0 is now changed from value= 0 to value= False, though we cannot distinguish the difference. This is a trick commonly called thresholding technique.

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.