1

I have a series of separate rasters which represent the cloud cover over the same area but in different months. Each raster has 2 values: nan for "no cloud" and 255 for "cloud". What i want to do is to create a single mask, where each pixel has a value of nan if ALL the separate rasters have nan as a value for that pixel, and a value of 255 if ANY raster (even only one is enough) has a value of 255 for that pixel. I'm using QGIS and I guess the raster calculator should be used for this, but I have no clue about how to do it and I've had no luck searching for solutions so far because I don't know how to even call the operation I'm trying to do. I tried to add the rasters but I got a weird result.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Simona
  • 313
  • 1
  • 10

2 Answers2

2

I don't see how you could do that without conditionals, and Conditional Statements in QGIS raster calculator? suggests (and I think too) that the default QGIS raster calculator doesn't support conditionals.

But that link provides a link to RaserCalc, which is another calculator plugin that does support conditionals.

Alternatively, if you're ok with using the GRASS plugin, you could do this with r.series input=your_map1,your_map2,... output=your_output method=average. You could also use the GRASS raster calculator r.mapcalc, but r.series (I think) is or was really just a convenient raster calculator wrapper.

user55937
  • 1,293
  • 11
  • 18
  • 1
    In the end, I solved the problem by using r.series through Qgis' Processing toolbox, it was the simplest solution but very effective. Thank you. – Simona Aug 20 '15 at 22:12
1

The better way to do this is to set a '1' for 'no cloud' and '0' or 'nan' for cloud. Then you can just multiply them together and all the 1's make 1 and a single 0 sets it all to 0.

@user55937 has the solution, though I think it can do conditionals. Try something like:

not(("Raster1@1" = 255) OR ("Raster2@1" = 255))

which should return 1 if they are all not 255, and 0 if one is.

Alex Leith
  • 13,453
  • 30
  • 69